diff --git a/docs/development_guide/build/doctrees/api_reference/api_adc.doctree b/docs/development_guide/build/doctrees/api_reference/api_adc.doctree index a1228b78..404c1be1 100644 Binary files a/docs/development_guide/build/doctrees/api_reference/api_adc.doctree and b/docs/development_guide/build/doctrees/api_reference/api_adc.doctree differ diff --git a/docs/development_guide/build/doctrees/api_reference/api_dma.doctree b/docs/development_guide/build/doctrees/api_reference/api_dma.doctree index ba9e3c14..d68d95f2 100644 Binary files a/docs/development_guide/build/doctrees/api_reference/api_dma.doctree and b/docs/development_guide/build/doctrees/api_reference/api_dma.doctree differ diff --git a/docs/development_guide/build/doctrees/api_reference/api_pwm.doctree b/docs/development_guide/build/doctrees/api_reference/api_pwm.doctree index 70f8669a..ccc69bb4 100644 Binary files a/docs/development_guide/build/doctrees/api_reference/api_pwm.doctree and b/docs/development_guide/build/doctrees/api_reference/api_pwm.doctree differ diff --git a/docs/development_guide/build/doctrees/api_reference/api_uart.doctree b/docs/development_guide/build/doctrees/api_reference/api_uart.doctree index a314eaa2..58c0215d 100644 Binary files a/docs/development_guide/build/doctrees/api_reference/api_uart.doctree and b/docs/development_guide/build/doctrees/api_reference/api_uart.doctree differ diff --git a/docs/development_guide/build/doctrees/environment.pickle b/docs/development_guide/build/doctrees/environment.pickle index 6ae04a70..bf9b39c2 100644 Binary files a/docs/development_guide/build/doctrees/environment.pickle and b/docs/development_guide/build/doctrees/environment.pickle differ diff --git a/docs/development_guide/build/doctrees/get_started/Linux_quick_start_ubuntu.doctree b/docs/development_guide/build/doctrees/get_started/Linux_quick_start_ubuntu.doctree index 2bdd2716..d3687fe8 100644 Binary files a/docs/development_guide/build/doctrees/get_started/Linux_quick_start_ubuntu.doctree and b/docs/development_guide/build/doctrees/get_started/Linux_quick_start_ubuntu.doctree differ diff --git a/docs/development_guide/build/doctrees/get_started/Windows_quick_start_cdk.doctree b/docs/development_guide/build/doctrees/get_started/Windows_quick_start_cdk.doctree index d92eac94..14bfa095 100644 Binary files a/docs/development_guide/build/doctrees/get_started/Windows_quick_start_cdk.doctree and b/docs/development_guide/build/doctrees/get_started/Windows_quick_start_cdk.doctree differ diff --git a/docs/development_guide/build/doctrees/get_started/connecting_hardware.doctree b/docs/development_guide/build/doctrees/get_started/connecting_hardware.doctree index 05dec28c..c2dbb680 100644 Binary files a/docs/development_guide/build/doctrees/get_started/connecting_hardware.doctree and b/docs/development_guide/build/doctrees/get_started/connecting_hardware.doctree differ diff --git a/docs/development_guide/build/doctrees/get_started/get_started.doctree b/docs/development_guide/build/doctrees/get_started/get_started.doctree index d312a915..86a791ab 100644 Binary files a/docs/development_guide/build/doctrees/get_started/get_started.doctree and b/docs/development_guide/build/doctrees/get_started/get_started.doctree differ diff --git a/docs/development_guide/build/doctrees/index.doctree b/docs/development_guide/build/doctrees/index.doctree index bad44411..c3f116b9 100644 Binary files a/docs/development_guide/build/doctrees/index.doctree and b/docs/development_guide/build/doctrees/index.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/advance samples/boot2_iap_info.doctree b/docs/development_guide/build/doctrees/samples/advance samples/boot2_iap_info.doctree index 95998b1c..014d5106 100644 Binary files a/docs/development_guide/build/doctrees/samples/advance samples/boot2_iap_info.doctree and b/docs/development_guide/build/doctrees/samples/advance samples/boot2_iap_info.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/advance samples/shell_demo.doctree b/docs/development_guide/build/doctrees/samples/advance samples/shell_demo.doctree index 9aca9b8c..51e44ea3 100644 Binary files a/docs/development_guide/build/doctrees/samples/advance samples/shell_demo.doctree and b/docs/development_guide/build/doctrees/samples/advance samples/shell_demo.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/adc_key_demo.doctree b/docs/development_guide/build/doctrees/samples/basic samples/adc/adc_key_demo.doctree similarity index 88% rename from docs/development_guide/build/doctrees/samples/basic samples/adc_key_demo.doctree rename to docs/development_guide/build/doctrees/samples/basic samples/adc/adc_key_demo.doctree index 1bc5424c..2cba4695 100644 Binary files a/docs/development_guide/build/doctrees/samples/basic samples/adc_key_demo.doctree and b/docs/development_guide/build/doctrees/samples/basic samples/adc/adc_key_demo.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/adc/index.doctree b/docs/development_guide/build/doctrees/samples/basic samples/adc/index.doctree new file mode 100644 index 00000000..fc05e202 Binary files /dev/null and b/docs/development_guide/build/doctrees/samples/basic samples/adc/index.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/breath_pwm_demo.doctree b/docs/development_guide/build/doctrees/samples/basic samples/breath_pwm_demo.doctree deleted file mode 100644 index 73f2b175..00000000 Binary files a/docs/development_guide/build/doctrees/samples/basic samples/breath_pwm_demo.doctree and /dev/null differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/dma_m2m_demo.doctree b/docs/development_guide/build/doctrees/samples/basic samples/dma/dma_m2m_demo.doctree similarity index 92% rename from docs/development_guide/build/doctrees/samples/basic samples/dma_m2m_demo.doctree rename to docs/development_guide/build/doctrees/samples/basic samples/dma/dma_m2m_demo.doctree index 2436f2cc..35807957 100644 Binary files a/docs/development_guide/build/doctrees/samples/basic samples/dma_m2m_demo.doctree and b/docs/development_guide/build/doctrees/samples/basic samples/dma/dma_m2m_demo.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/dma/index.doctree b/docs/development_guide/build/doctrees/samples/basic samples/dma/index.doctree new file mode 100644 index 00000000..04ee9b6a Binary files /dev/null and b/docs/development_guide/build/doctrees/samples/basic samples/dma/index.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/blink_demo.doctree b/docs/development_guide/build/doctrees/samples/basic samples/gpio/blink_demo.doctree similarity index 87% rename from docs/development_guide/build/doctrees/samples/basic samples/blink_demo.doctree rename to docs/development_guide/build/doctrees/samples/basic samples/gpio/blink_demo.doctree index b10a0a86..102bd972 100644 Binary files a/docs/development_guide/build/doctrees/samples/basic samples/blink_demo.doctree and b/docs/development_guide/build/doctrees/samples/basic samples/gpio/blink_demo.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/button_demo.doctree b/docs/development_guide/build/doctrees/samples/basic samples/gpio/button_demo.doctree similarity index 84% rename from docs/development_guide/build/doctrees/samples/basic samples/button_demo.doctree rename to docs/development_guide/build/doctrees/samples/basic samples/gpio/button_demo.doctree index 565c1292..37d6dc4f 100644 Binary files a/docs/development_guide/build/doctrees/samples/basic samples/button_demo.doctree and b/docs/development_guide/build/doctrees/samples/basic samples/gpio/button_demo.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/gpio/index.doctree b/docs/development_guide/build/doctrees/samples/basic samples/gpio/index.doctree new file mode 100644 index 00000000..880585e0 Binary files /dev/null and b/docs/development_guide/build/doctrees/samples/basic samples/gpio/index.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/i2c_eeprom_demo.doctree b/docs/development_guide/build/doctrees/samples/basic samples/i2c/i2c_eeprom_demo.doctree similarity index 92% rename from docs/development_guide/build/doctrees/samples/basic samples/i2c_eeprom_demo.doctree rename to docs/development_guide/build/doctrees/samples/basic samples/i2c/i2c_eeprom_demo.doctree index 72c4bacc..78182542 100644 Binary files a/docs/development_guide/build/doctrees/samples/basic samples/i2c_eeprom_demo.doctree and b/docs/development_guide/build/doctrees/samples/basic samples/i2c/i2c_eeprom_demo.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/i2c/index.doctree b/docs/development_guide/build/doctrees/samples/basic samples/i2c/index.doctree new file mode 100644 index 00000000..63648147 Binary files /dev/null and b/docs/development_guide/build/doctrees/samples/basic samples/i2c/index.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/mtimer/index.doctree b/docs/development_guide/build/doctrees/samples/basic samples/mtimer/index.doctree new file mode 100644 index 00000000..2faa0348 Binary files /dev/null and b/docs/development_guide/build/doctrees/samples/basic samples/mtimer/index.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/mtimer_demo.doctree b/docs/development_guide/build/doctrees/samples/basic samples/mtimer/mtimer_demo.doctree similarity index 82% rename from docs/development_guide/build/doctrees/samples/basic samples/mtimer_demo.doctree rename to docs/development_guide/build/doctrees/samples/basic samples/mtimer/mtimer_demo.doctree index bf1ee834..dfb41839 100644 Binary files a/docs/development_guide/build/doctrees/samples/basic samples/mtimer_demo.doctree and b/docs/development_guide/build/doctrees/samples/basic samples/mtimer/mtimer_demo.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/pwm/index.doctree b/docs/development_guide/build/doctrees/samples/basic samples/pwm/index.doctree new file mode 100644 index 00000000..932b70dd Binary files /dev/null and b/docs/development_guide/build/doctrees/samples/basic samples/pwm/index.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/pwm/pwm_breath_demo.doctree b/docs/development_guide/build/doctrees/samples/basic samples/pwm/pwm_breath_demo.doctree new file mode 100644 index 00000000..b5f0a9f5 Binary files /dev/null and b/docs/development_guide/build/doctrees/samples/basic samples/pwm/pwm_breath_demo.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/pwm/pwm_step_motor.doctree b/docs/development_guide/build/doctrees/samples/basic samples/pwm/pwm_step_motor.doctree new file mode 100644 index 00000000..991d75a5 Binary files /dev/null and b/docs/development_guide/build/doctrees/samples/basic samples/pwm/pwm_step_motor.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/spi/index.doctree b/docs/development_guide/build/doctrees/samples/basic samples/spi/index.doctree new file mode 100644 index 00000000..84726f2d Binary files /dev/null and b/docs/development_guide/build/doctrees/samples/basic samples/spi/index.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/spi_lcd_demo.doctree b/docs/development_guide/build/doctrees/samples/basic samples/spi/spi_lcd_demo.doctree similarity index 93% rename from docs/development_guide/build/doctrees/samples/basic samples/spi_lcd_demo.doctree rename to docs/development_guide/build/doctrees/samples/basic samples/spi/spi_lcd_demo.doctree index 288db2a3..3cf7a9fb 100644 Binary files a/docs/development_guide/build/doctrees/samples/basic samples/spi_lcd_demo.doctree and b/docs/development_guide/build/doctrees/samples/basic samples/spi/spi_lcd_demo.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/uart/index.doctree b/docs/development_guide/build/doctrees/samples/basic samples/uart/index.doctree new file mode 100644 index 00000000..6cc4c845 Binary files /dev/null and b/docs/development_guide/build/doctrees/samples/basic samples/uart/index.doctree differ diff --git a/docs/development_guide/build/doctrees/samples/basic samples/uart_loopback_demo.doctree b/docs/development_guide/build/doctrees/samples/basic samples/uart/uart_loopback_demo.doctree similarity index 58% rename from docs/development_guide/build/doctrees/samples/basic samples/uart_loopback_demo.doctree rename to docs/development_guide/build/doctrees/samples/basic samples/uart/uart_loopback_demo.doctree index 588aa041..5cf6223f 100644 Binary files a/docs/development_guide/build/doctrees/samples/basic samples/uart_loopback_demo.doctree and b/docs/development_guide/build/doctrees/samples/basic samples/uart/uart_loopback_demo.doctree differ diff --git a/docs/development_guide/build/html/_images/bl706_avb_ck_link.png b/docs/development_guide/build/html/_images/bl706_avb_ck_link.png new file mode 100644 index 00000000..da39cae4 Binary files /dev/null and b/docs/development_guide/build/html/_images/bl706_avb_ck_link.png differ diff --git a/docs/development_guide/build/html/_images/bl706_avb_rv_debugger_plus.png b/docs/development_guide/build/html/_images/bl706_avb_rv_debugger_plus.png new file mode 100644 index 00000000..8deac670 Binary files /dev/null and b/docs/development_guide/build/html/_images/bl706_avb_rv_debugger_plus.png differ diff --git a/docs/development_guide/source/samples/basic samples/img/blink_breath_sch.png b/docs/development_guide/build/html/_images/blink_breath_sch1.png similarity index 100% rename from docs/development_guide/source/samples/basic samples/img/blink_breath_sch.png rename to docs/development_guide/build/html/_images/blink_breath_sch1.png diff --git a/docs/development_guide/build/html/_images/cdk1.png b/docs/development_guide/build/html/_images/cdk1.png index ef477b17..7175dc0a 100644 Binary files a/docs/development_guide/build/html/_images/cdk1.png and b/docs/development_guide/build/html/_images/cdk1.png differ diff --git a/docs/development_guide/build/html/_images/pwm_step_motor.gif b/docs/development_guide/build/html/_images/pwm_step_motor.gif new file mode 100644 index 00000000..09a0cee7 Binary files /dev/null and b/docs/development_guide/build/html/_images/pwm_step_motor.gif differ diff --git a/docs/development_guide/build/html/_images/pwm_step_motor.png b/docs/development_guide/build/html/_images/pwm_step_motor.png new file mode 100644 index 00000000..5d8faec1 Binary files /dev/null and b/docs/development_guide/build/html/_images/pwm_step_motor.png differ diff --git a/docs/development_guide/build/html/_images/pwm_step_motor1.png b/docs/development_guide/build/html/_images/pwm_step_motor1.png new file mode 100644 index 00000000..3180f0b6 Binary files /dev/null and b/docs/development_guide/build/html/_images/pwm_step_motor1.png differ diff --git a/docs/development_guide/build/html/_images/pwm_step_motor2.png b/docs/development_guide/build/html/_images/pwm_step_motor2.png new file mode 100644 index 00000000..775d5da5 Binary files /dev/null and b/docs/development_guide/build/html/_images/pwm_step_motor2.png differ diff --git a/docs/development_guide/build/html/_images/pwm_step_motor3.png b/docs/development_guide/build/html/_images/pwm_step_motor3.png new file mode 100644 index 00000000..a2b8d8d2 Binary files /dev/null and b/docs/development_guide/build/html/_images/pwm_step_motor3.png differ diff --git a/docs/development_guide/build/html/_images/shell_demo.gif b/docs/development_guide/build/html/_images/shell_demo.gif new file mode 100644 index 00000000..7cbd5138 Binary files /dev/null and b/docs/development_guide/build/html/_images/shell_demo.gif differ diff --git a/docs/development_guide/build/html/_images/sipeed_rv_debugger_3.png b/docs/development_guide/build/html/_images/sipeed_rv_debugger_3.png index fea51b2e..4db6ab8c 100644 Binary files a/docs/development_guide/build/html/_images/sipeed_rv_debugger_3.png and b/docs/development_guide/build/html/_images/sipeed_rv_debugger_3.png differ diff --git a/docs/development_guide/build/html/_images/sipeed_rv_debugger_4.png b/docs/development_guide/build/html/_images/sipeed_rv_debugger_4.png new file mode 100644 index 00000000..f971757a Binary files /dev/null and b/docs/development_guide/build/html/_images/sipeed_rv_debugger_4.png differ diff --git a/docs/development_guide/build/html/_images/sipeed_rv_debugger_plus.png b/docs/development_guide/build/html/_images/sipeed_rv_debugger_plus.png new file mode 100644 index 00000000..89673229 Binary files /dev/null and b/docs/development_guide/build/html/_images/sipeed_rv_debugger_plus.png differ diff --git a/docs/development_guide/build/html/_images/step_motor.png b/docs/development_guide/build/html/_images/step_motor.png new file mode 100644 index 00000000..8281cf8c Binary files /dev/null and b/docs/development_guide/build/html/_images/step_motor.png differ diff --git a/docs/development_guide/build/html/_images/step_motor_info.png b/docs/development_guide/build/html/_images/step_motor_info.png new file mode 100644 index 00000000..ce561ca6 Binary files /dev/null and b/docs/development_guide/build/html/_images/step_motor_info.png differ diff --git a/docs/development_guide/build/html/_images/uln2003.png b/docs/development_guide/build/html/_images/uln2003.png new file mode 100644 index 00000000..7ef6a395 Binary files /dev/null and b/docs/development_guide/build/html/_images/uln2003.png differ diff --git a/docs/development_guide/build/html/_sources/api_reference/api_adc.rst.txt b/docs/development_guide/build/html/_sources/api_reference/api_adc.rst.txt index b97eba7b..b18f24ac 100644 --- a/docs/development_guide/build/html/_sources/api_reference/api_adc.rst.txt +++ b/docs/development_guide/build/html/_sources/api_reference/api_adc.rst.txt @@ -3,13 +3,238 @@ ADC 设备 简介 ------------------------ +ADC (Analog-to-digital Converter) 是用于将模拟形式的连续信号转换为数字形式的离散信号的一类设备,他可以将外围电路传感器产生的模拟信号转化为机器可识别的数字信号。 +博流系列MCU中的ADC设备具有以下特性 + +- 可以选择 12/14/16 bits转换结果输出 +- ADC最大工作时钟为2MHZ +- 支持2.0V,3.2V可选内部参考电压 +- 支持DMA将转换结果搬运到内存 +- 支持单次单通道转换、连续单通道转换、单次多通道转换和连续多通道转换模式四种模式 +- 支持单端与差分两种输入模式 +- 12路外部模拟通道 +- 2路DAC内部通道 +- 1路VBAT/2通道 ADC 设备结构体定义 ------------------------ +.. code-block:: C + + typedef struct adc_device { + struct device parent; + adc_clk_div_t clk_div; + adc_vref_t vref; + bool continuous_conv_mode; + bool differential_mode; + adc_data_width_t data_width; + adc_fifo_threshold_t fifo_threshold; + adc_pga_gain_t gain; + } adc_device_t; + +- parent 继承父类属性 +- clk_div ADC模块时钟内部分频 +- vref 参考电压选择 2.0/3.2V可选 +- continuous_conv_mode 是否选择为连续模式,若为连续模式,则一次adc_start操作,ADC连续工作,直到adc_stop。否则,每adc_start一次,adc仅转换一次结果。 +- differential_mode 选择是否为差分模式,若为差分模式,则可以测量负电压。 +- data_width 测量宽度选择,ADC实际精度为12bits,但是通过OSR多次取平均可以达到14bits/16bits的精度,注意,当选择更高的数据宽度后,频率会因为取平均而下降。详情可参考枚举信息。 +- fifo_threshold 此参数影响DMA搬运阈值以及ADC FIFO中断阈值 +- gain ADC对输入信号的增益选择 +- 其他待补充 ADC 设备参数配置表 ------------------------ +每一个 ADC 设备都有一个参数配置宏,宏定义位于 ``bsp/board/xxx`` 目录下 ``peripheral_config.h`` 文件,变量定义位于 ``hal_adc.c`` 中,因此无需用户自己定义变量。当用户打开对应设备的宏,该设备的配置才生效。例如打开宏 ``BSP_USING_ADC0`` 即生效,同时 ``ADC`` 设备就可以进行注册和使用了。 + +.. code-block:: C + + /*参数配置宏*/ + #if defined(BSP_USING_ADC0) + #ifndef ADC0_CONFIG + #define ADC0_CONFIG \ + { \ + .clk_div = ADC_CLOCK_DIV_32, \ + .vref = ADC_VREF_3P2V, \ + .continuous_conv_mode = DISABLE, \ + .differential_mode = DISABLE, \ + .data_width = ADC_DATA_WIDTH_16B_WITH_256_AVERAGE, \ + .fifo_threshold = ADC_FIFO_THRESHOLD_1BYTE, \ + .gain = ADC_GAIN_1 \ + } + #endif + #endif + + /*变量定义*/ + static adc_device_t adcx_device[ADC_MAX_INDEX] = { + #ifdef BSP_USING_ADC0 + ADC0_CONFIG, + #endif + }; + +.. note:: 上述配置可以通过 ``ADC_DEV(dev)->xxx`` 进行修改,只能在调用 ``device_open`` 之前使用。 + ADC 设备接口 ------------------------ +ADC 设备接口全部遵循标准设备驱动管理层提供的接口。 + + +**ADC_register** +^^^^^^^^^^^^^^^^^^^^^^^^ + +``adc_register`` 用来注册一个 ADC 设备,在注册之前需要打开对应 ADC 设备的宏定义。例如定义宏 ``BSP_USING_ADC0`` 方可使用 ``ADC0`` 设备,注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 ``ADC0`` 设备。 + +.. code-block:: C + + int ADC_register(enum ADC_index_type index, const char *name, uint16_t flag); + +- index 要注册的设备索引 +- name 为注册的设备命名 +- flag 默认可读可写属性 + +``index`` 用来选择 ADC 设备配置,一个 index 对应一个 ADC 设备配置,比如 ``ADC0_INDEX`` 对应 ``ADC0_CONFIG`` 配置,``index`` 有如下可选类型 + +.. code-block:: C + + enum ADC_index_type + { + #ifdef BSP_USING_ADC0 + ADC0_INDEX, + #endif + ADC_MAX_INDEX + }; + +**device_open** +^^^^^^^^^^^^^^^^ + +``device_open`` 用于 ADC 设备的打开,``oflag`` 表示以何种方式打开。 + +.. code-block:: C + + int device_open(struct device *dev, uint16_t oflag); + +- dev 设备句柄 +- oflag 设备的打开方式 +- return 错误码,0 表示打开成功,其他表示错误 + +``oflag`` 可以写入以下参数: + +.. code-block:: C + + #define DEVICE_OFLAG_STREAM_TX 0x001 /* 设备以轮训发送模式打开 */ + #define DEVICE_OFLAG_STREAM_RX 0x002 /* 设备以轮训接收模式打开 */ + #define DEVICE_OFLAG_INT_TX 0x004 /* 设备以中断发送模式打开 */ + #define DEVICE_OFLAG_INT_RX 0x008 /* 设备以中断接收模式打开 */ + #define DEVICE_OFLAG_DMA_TX 0x010 /* 设备以 DMA 发送模式打开 */ + #define DEVICE_OFLAG_DMA_RX 0x020 /* 设备以 DMA 接收模式打开 */ + +**device_close** +^^^^^^^^^^^^^^^^ + +``device_close`` 用于设备的关闭。 + +.. code-block:: C + + int device_close(struct device *dev); + +- dev 设备句柄 +- return 错误码,0 表示关闭成功,其他表示错误 + +**device_control** +^^^^^^^^^^^^^^^^^^^ + +``device_control`` 用于根据命令对 ADC 设备进行控制和参数的修改。 + +.. code-block:: C + + int device_control(struct device *dev, int cmd, void *args); + +- dev 设备句柄 +- cmd 设备控制命令 +- args 控制参数 +- return 不同的控制命令返回的意义不同。 + +串口设备除了标准的控制命令,还具有自己特殊的控制命令。 + +.. code-block:: C + + #define DEVICE_CTRL_ADC_CHANNEL_START 0x10 + #define DEVICE_CTRL_ADC_CHANNEL_STOP 0x11 + #define DEVICE_CTRL_ADC_CHANNEL_CONFIG 0x12 + #define DEVICE_CTRL_ADC_VBAT_ON 0x13 + #define DEVICE_CTRL_ADC_VBAT_OFF 0x14 + #define DEVICE_CTRL_ADC_TSEN_ON 0x15 + #define DEVICE_CTRL_ADC_TSEN_OFF 0x16 + +``args`` 根据不同的 ``cmd`` 传入不同,具体如下: + + ++-----------------------------------+-----------------------+-------------------------------------+ +|cmd |args |description | ++===================================+=======================+=====================================+ +|DEVICE_CTRL_SET_INT |ADC_it_type |开启ADC设备中断 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_CLR_INT |ADC_it_type |关闭ADC设备中断 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_CONFIG |ADC_param_cfg_t* |修改ADC配置 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_CHANNEL_CONFIG |adc_channel_cfg_t* |配置ADC通道信息 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ATTACH_RX_DMA |struct device* |链接接收dma设备 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_CHANNEL_START |struct device* |开始/继续 ADC转换 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_CHANNEL_STOP |NULL |停止ADC转换 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_VBAT_ON |NULL |打开内部VDD测量电路 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_VBAT_OFF |NULL |关闭内部VDD测量电路 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_TSEN_ON |NULL |打开内部温度测量电路(需硬件支持) | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_TSEN_OFF |uint32_t* |关闭内部温度测量电路(需硬件支持) | ++-----------------------------------+-----------------------+-------------------------------------+ + + +**device_read** +^^^^^^^^^^^^^^^^ + +``device_read`` 用于 ADC 设备数据的接收,接收方式根据打开方式可以是轮询、中断、dma。 + +.. code-block:: C + + int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); + +- dev 设备句柄 +- pos 无作用 +- buffer 要读入的 buffer 缓冲区 +- size 要读入的长度 +- return 错误码,0 表示读入成功,其他表示错误 + +**device_set_callback** +^^^^^^^^^^^^^^^^^^^^^^^^ + +``device_set_callback`` 用于注册一个ADC阈值中断回调函数。 + +.. code-block:: C + + int device_set_callback(struct device *dev, void (*callback)(struct device *dev, void *args, uint32_t size, uint32_t event)); + +- dev 设备句柄 +- callback 要注册的中断回调函数 + + - dev 设备句柄 + - args 接收发送缓冲区,数据类型为 uint8_t* + - size 传输长度 + - event 中断事件类型 + +串口设备 ``event`` 类型如下 + +.. code-block:: C + + enum ADC_event_type + { + ADC_EVENT_FIFO_READY, + ADC_EVENT_OVERRUN, + ADC_EVENT_UNDERRUN, + }; \ No newline at end of file diff --git a/docs/development_guide/build/html/_sources/api_reference/api_ble.rst.txt b/docs/development_guide/build/html/_sources/api_reference/api_ble.rst.txt index 388658b1..12f6a5c4 100644 --- a/docs/development_guide/build/html/_sources/api_reference/api_ble.rst.txt +++ b/docs/development_guide/build/html/_sources/api_reference/api_ble.rst.txt @@ -17,7 +17,7 @@ BLE - BLE协议栈的架构: .. figure:: img/image1.png - + 总共有3个主要层,共同构成了一个完整的蓝牙低能耗协议栈 + + 总共有3个主要层,共同构成了一个完整的蓝牙低能耗协议栈 - Host:这一层位于应用程序之下,由多个(非实时)网络和传输协议组成,使应用程序能够以标准和互操作的方式与对等设备通信。 - Controller:控制器实现了链路层(LE LL),这是一种低层次的实时协议,它与无线电硬件一起提供了空中通信的标准互操作。LL处理包的接收和传输,保证数据的传递,并处理所有LL控制程序。 - Radio Hardware:实现所需的模拟和数字基带功能块,允许链路层固件在频谱的2.4GHz波段发送和接收。 @@ -25,7 +25,7 @@ BLE - 主控Host: .. figure:: img/image2.png - * 蓝牙Host层实现了所有高级协议和配置文件,最重要的是它为应用程序提供了高级API + * 蓝牙Host层实现了所有高级协议和配置文件,最重要的是它为应用程序提供了高级API - HCI:Host与controller接口 - L2CAP:逻辑链路控制和适应协议 - GATT:通用属性配置层(Generic Attribute Profile) @@ -34,14 +34,14 @@ BLE - 应用Application * 应用层是用户开发实际蓝牙应用的地方,包含必要的协议栈参数设置,以及各种功能函数的调用。我们分别从蓝牙从机和蓝牙主机两种设备来分析。 - * 蓝牙从机 + * 蓝牙从机 - 相关硬件和基础服务初始化 - 设置广播参数:广播数据,广播间隔,扫描回应等参数或者数据 - 设置Profile:添加从机服务、特征值,还有设置回调函数用于接收主机数据等 - 设置配对参数(可选) - 启动广播,开始运行 - 等待相关事件,及事件处理,例如收到主机发来的数据,被链接等等 - * 蓝牙主机 + * 蓝牙主机 - 相关硬件和基础服务初始化 - 设置扫描参数 - 设置连接参数 @@ -95,8 +95,8 @@ API参考 * @param[in] param: 指向广播配置参数指针 * @param[in] ad: 指向广播包中数据指针 * @param[in] ad_len: 广播包中数据的长度 - * @param[in] sd: 指向扫描响应包数据指针 - * @param[in] sd_len: 扫描响应包数据的长度 + * @param[in] sd: 指向扫描响应包数据指针 + * @param[in] sd_len: 扫描响应包数据的长度 * @return 0:成功,!=0:失败 */ @@ -110,8 +110,8 @@ API参考 * function 更新BLE广播数据 * @param[in] ad: 指向广播包中数据指针 * @param[in] ad_len: 广播包中数据的长度 - * @param[in] sd: 指向扫描响应包数据指针 - * @param[in] sd_len: 扫描响应包数据的长度 + * @param[in] sd: 指向扫描响应包数据指针 + * @param[in] sd_len: 扫描响应包数据的长度 * @return 0:成功,!=0:失败 */ @@ -121,7 +121,7 @@ API参考 :: /** - * function 停止BLE广播 + * function 停止BLE广播 * @param[in] 空 * @return 0:成功,!=0:失败 */ diff --git a/docs/development_guide/build/html/_sources/api_reference/api_clock.rst.txt b/docs/development_guide/build/html/_sources/api_reference/api_clock.rst.txt index c6958a71..da42102c 100644 --- a/docs/development_guide/build/html/_sources/api_reference/api_clock.rst.txt +++ b/docs/development_guide/build/html/_sources/api_reference/api_clock.rst.txt @@ -46,9 +46,9 @@ - type 获取的外设时钟频率类型 ``type`` 提供以下几种类型 - + .. code-block:: C - + enum peripheral_clock_type { PERIPHERAL_CLOCK_UART = 0, diff --git a/docs/development_guide/build/html/_sources/api_reference/api_dma.rst.txt b/docs/development_guide/build/html/_sources/api_reference/api_dma.rst.txt index d4306519..182c791b 100644 --- a/docs/development_guide/build/html/_sources/api_reference/api_dma.rst.txt +++ b/docs/development_guide/build/html/_sources/api_reference/api_dma.rst.txt @@ -29,7 +29,7 @@ DMA 设备结构体定义 uint8_t dst_burst_size; uint8_t src_width; uint8_t dst_width; - dma_lli_ctrl_t *lli_cfg; + dma_lli_ctrl_t *lli_cfg; } dma_device_t; - parent 继承父类属性 @@ -60,7 +60,7 @@ DMA 设备结构体定义 .. code-block:: C - #define DMA_LLI_ONCE_MODE 0 + #define DMA_LLI_ONCE_MODE 0 #define DMA_LLI_CYCLE_MODE 1 ``src_req`` 提供以下类型 @@ -76,8 +76,8 @@ DMA 设备结构体定义 #define DMA_REQUEST_I2C0_TX 0x00000007 /*!< DMA request peripheral:I2C TX */ #define DMA_REQUEST_SPI0_RX 0x0000000A /*!< DMA request peripheral:SPI RX */ #define DMA_REQUEST_SPI0_TX 0x0000000B /*!< DMA request peripheral:SPI TX */ - #define DMA_REQUEST_I2S_RX 0x00000014 /*!< DMA request peripheral:I2S RX */ - #define DMA_REQUEST_I2S_TX 0x00000015 /*!< DMA request peripheral:I2S TX */ + #define DMA_REQUEST_I2S_RX 0x00000014 /*!< DMA request peripheral:I2S RX */ + #define DMA_REQUEST_I2S_TX 0x00000015 /*!< DMA request peripheral:I2S TX */ #define DMA_REQUEST_ADC0 0x00000016 /*!< DMA request peripheral:ADC0 */ #define DMA_REQUEST_DAC0 0x00000017 /*!< DMA request peripheral:DAC0 */ #define DMA_REQUEST_USB_EP0 0x00000018 /*!< DMA request peripheral:USB EP0*/ @@ -102,8 +102,8 @@ DMA 设备结构体定义 #define DMA_REQUEST_I2C0_TX 0x00000007 /*!< DMA request peripheral:I2C TX */ #define DMA_REQUEST_SPI0_RX 0x0000000A /*!< DMA request peripheral:SPI RX */ #define DMA_REQUEST_SPI0_TX 0x0000000B /*!< DMA request peripheral:SPI TX */ - #define DMA_REQUEST_I2S_RX 0x00000014 /*!< DMA request peripheral:I2S RX */ - #define DMA_REQUEST_I2S_TX 0x00000015 /*!< DMA request peripheral:I2S TX */ + #define DMA_REQUEST_I2S_RX 0x00000014 /*!< DMA request peripheral:I2S RX */ + #define DMA_REQUEST_I2S_TX 0x00000015 /*!< DMA request peripheral:I2S TX */ #define DMA_REQUEST_ADC0 0x00000016 /*!< DMA request peripheral:ADC0 */ #define DMA_REQUEST_DAC0 0x00000017 /*!< DMA request peripheral:DAC0 */ #define DMA_REQUEST_USB_EP0 0x00000018 /*!< DMA request peripheral:USB EP0*/ @@ -172,7 +172,7 @@ DMA 设备参数配置表 } #endif #endif - + /*变量定义*/ static dma_device_t dmax_device[DMA_MAX_INDEX] = @@ -212,11 +212,11 @@ DMA 设备接口全部遵循标准设备驱动管理层提供的接口。并且 **dma_register** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``dma_register`` 用来注册一个 DMA 设备的一个通道,在注册之前需要打开对应 DMA 设备的通道宏定义。例如定义宏 ``BSP_USING_DMA_CH0`` 方可使用 ``DMA`` 设备的 0 通道,注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 ``DMA`` 设备的 0 通道。 .. code-block:: C - + int dma_register(enum dma_index_type index, const char *name, uint16_t flag); - index 要注册的设备索引 @@ -226,7 +226,7 @@ DMA 设备接口全部遵循标准设备驱动管理层提供的接口。并且 ``index`` 用来选择 DMA 设备某个通道的配置,一个 index 对应一个 DMA 设备的一个通道配置,比如 ``DMA_CH0_INDEX`` 对应 DMA 通道0 配置,``index`` 有如下可选类型 .. code-block:: C - + enum dma_index_type { #ifdef BSP_USING_DMA0_CH0 @@ -263,7 +263,7 @@ DMA 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -287,11 +287,11 @@ DMA 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_close(struct device *dev); + int device_close(struct device *dev); - dev 设备句柄 - return 错误码,0 表示关闭成功,其他表示错误 - + **device_control** ^^^^^^^^^^^^^^^^^^^ @@ -299,7 +299,7 @@ DMA 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_control(struct device *dev, int cmd, void *args); + int device_control(struct device *dev, int cmd, void *args); - dev 设备句柄 - cmd 设备控制命令 @@ -348,7 +348,7 @@ DMA 设备除了标准的控制命令,还具有自己特殊的控制命令。 - dev 设备句柄 - args 无用 - size 无用 - - event 中断事件类型 + - event 中断事件类型 DMA 设备 ``event`` 类型如下 diff --git a/docs/development_guide/build/html/_sources/api_reference/api_gpio.rst.txt b/docs/development_guide/build/html/_sources/api_reference/api_gpio.rst.txt index 2ccd7d19..95737f9e 100644 --- a/docs/development_guide/build/html/_sources/api_reference/api_gpio.rst.txt +++ b/docs/development_guide/build/html/_sources/api_reference/api_gpio.rst.txt @@ -27,7 +27,7 @@ GPIO 设备接口 ``gpio_set_mode`` 用来配置 gpio 的模式。 .. code-block:: C - + void gpio_set_mode(uint32_t pin, uint32_t mode); - pin 要配置的引脚 @@ -36,7 +36,7 @@ GPIO 设备接口 ``mode`` 提供以下几种类型 .. code-block:: C - + #define GPIO_OUTPUT_MODE 0 #define GPIO_OUTPUT_PP_MODE 1 #define GPIO_OUTPUT_PD_MODE 2 @@ -58,31 +58,31 @@ GPIO 设备接口 ``gpio_write`` 设置引脚电平 .. code-block:: C - + void gpio_write(uint32_t pin, uint32_t value); - pin 要设置的引脚 - value 要设置的电平 - + **gpio_toggle** ^^^^^^^^^^^^^^^^^^^^^^^^ ``gpio_toggle`` 翻转引脚电平 .. code-block:: C - + void gpio_toggle(uint32_t pin); - pin 要翻转的引脚 **gpio_read** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``gpio_read`` 读取引脚电平 .. code-block:: C - + int gpio_read(uint32_t pin); @@ -91,11 +91,11 @@ GPIO 设备接口 **gpio_attach_irq** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``gpio_attach_irq`` 为中断引脚附加中断回调函数 .. code-block:: C - + void gpio_attach_irq(uint32_t pin, void (*cbfun)(uint32_t pin)); - pin 要附加中断回调的引脚 @@ -103,11 +103,11 @@ GPIO 设备接口 **gpio_irq_enable** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``gpio_irq_enable`` 开启gpio某个引脚的中断 .. code-block:: C - + void gpio_irq_enable(uint32_t pin,uint8_t enabled); - pin 要开启或者关闭中断的引脚 diff --git a/docs/development_guide/build/html/_sources/api_reference/api_i2c.rst.txt b/docs/development_guide/build/html/_sources/api_reference/api_i2c.rst.txt index a6dca85e..4f606f87 100644 --- a/docs/development_guide/build/html/_sources/api_reference/api_i2c.rst.txt +++ b/docs/development_guide/build/html/_sources/api_reference/api_i2c.rst.txt @@ -30,7 +30,7 @@ I2C 设备结构体定义 - parent 继承父类属性 - ch i2c id,0 表示 i2c0,1 表示 i2c1 - mode i2c 传输模式,0 为使用硬件 i2c,1 为使用软件 i2c,当前软件 i2c 暂时无效 -- phase +- phase - 其他待补充 I2C 设备参数配置表 @@ -70,11 +70,11 @@ I2C 设备标准接口当前仅使用 ``device_open`` , 并提供标准的数据 **i2c_register** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``i2c_register`` 用来注册一个 I2C 设备,在注册之前需要打开对应 I2C 设备的宏定义。例如定义宏 ``BSP_USING_I2C0`` 方可使用 ``I2C0`` 设备,注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 ``I2C0`` 设备。 .. code-block:: C - + int i2c_register(enum i2c_index_type index, const char *name, uint16_t flag); - index 要注册的设备索引 @@ -84,7 +84,7 @@ I2C 设备标准接口当前仅使用 ``device_open`` , 并提供标准的数据 ``index`` 用来选择 I2C 设备,一个 index 对应一个 I2C 设备配置,比如 ``I2C0_INDEX`` 对应 ``I2C0_CONFIG`` 配置,``index`` 有如下可选类型 .. code-block:: C - + enum i2c_index_type { #ifdef BSP_USING_I2C0 @@ -100,7 +100,7 @@ I2C 设备标准接口当前仅使用 ``device_open`` , 并提供标准的数据 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -124,7 +124,7 @@ I2C 设备标准接口当前仅使用 ``device_open`` , 并提供标准的数据 .. code-block:: C - int i2c_transfer(struct device *dev, i2c_msg_t msgs[], uint32_t num); + int i2c_transfer(struct device *dev, i2c_msg_t msgs[], uint32_t num); - dev 设备句柄 - msgs 需要传输的消息 diff --git a/docs/development_guide/build/html/_sources/api_reference/api_pwm.rst.txt b/docs/development_guide/build/html/_sources/api_reference/api_pwm.rst.txt index b298424f..0c30b6e1 100644 --- a/docs/development_guide/build/html/_sources/api_reference/api_pwm.rst.txt +++ b/docs/development_guide/build/html/_sources/api_reference/api_pwm.rst.txt @@ -6,7 +6,7 @@ PWM 设备 脉冲宽度调制(Pulse width modulation,简称 PWM)是一种用数字方式实现模拟电压控制的技术。它是通过对一系列脉冲的宽度进行调制,等效出所需要的波形(包含形状以及幅值),对模拟信号电平进行数字编码,也就是说通过调节占空比的变化来调节信号、能量等的变化,占空比就是指在一个周期内,信号处于高电平的时间占据整个信号周期的百分比,例如方波的占空比就是50%。博流系列 MCU 中 DMA 设备具有以下特性: -- 支持5通道PWM信号生成 +- 支持5通道 PWM 信号生成 - 三种时钟源可选择(总线时钟 、晶振时钟 、慢速时钟 <32k>),搭配 16-bit 时钟分频器 - 双门限值域设定,增加脉冲弹性 @@ -15,21 +15,29 @@ PWM 设备结构体定义 .. code-block:: C - typedef struct pwm_device - { + typedef struct pwm_device { struct device parent; uint8_t ch; - uint32_t frequency; - uint8_t dutycycle; + uint8_t polarity_invert_mode; + uint16_t period; + uint16_t threshold_low; + uint16_t threshold_high; uint16_t it_pulse_count; + } pwm_device_t; - parent 继承父类属性 - ch 通道号,使能PWM通道0则ch为0,使能PWM通道0则ch为1,以此类推 -- frequency 默认频率 -- dutycycle 默认占空比(0-100) +- polarity_invert_mode 极性翻转使能 +- period PWM 周期值 +- threshold_low PWM 低门限阈值 +- threshold_high PWM 高门限阈值 - it_pulse_count 触发中断条件的周期计数值 +.. note:: PWM 实际频率 = PWM 时钟源/分频/period ,period 非 PWM 实际周期, + +.. note:: PWM 占空比 = threshold_low/threshold_high * 100% + PWM 设备参数配置表 ------------------------ @@ -40,15 +48,19 @@ PWM 设备参数配置表 /*参数配置宏*/ #if defined(BSP_USING_PWM_CH2) #ifndef PWM_CH2_CONFIG - #define PWM_CH2_CONFIG \ - { \ - .ch = 2, \ - .frequency = 1000000, \ - .dutycycle = 0, \ - } + #define PWM_CH2_CONFIG \ + { \ + .ch = 2, \ + .polarity_invert_mode = DISABLE, \ + .period = 0, \ + .threshold_low = 0, \ + .threshold_high = 0, \ + .it_pulse_count = 0, \ + } #endif #endif + /*变量定义*/ static pwm_device_t pwmx_device[PWM_MAX_INDEX] = { #ifdef BSP_USING_PWM_CH0 @@ -77,11 +89,11 @@ PWM 设备接口全部遵循标准设备驱动管理层提供的接口。并且 **pwm_register** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``pwm_register`` 用来注册一个 PWM 设备的一个通道,在注册之前需要打开对应 PWM 设备某个通道的宏定义,例如定义 ``BSP_USING_PWM_CH0`` 方可使用 ``PWM`` 通道0 设备。注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 PWM 设备。 .. code-block:: C - + int pwm_register(enum pwm_index_type index, const char *name, uint16_t flag); - index 要注册的设备索引 @@ -91,7 +103,7 @@ PWM 设备接口全部遵循标准设备驱动管理层提供的接口。并且 ``index`` 用来选择 PWM 设备某个通道的配置,一个 index 对应一个 PWM 设备的一个通道配置,比如 ``PWM_CH0_INDEX`` 对应 PWM 通道0 配置,``index`` 有如下可选类型 .. code-block:: C - + enum pwm_index_type { #ifdef BSP_USING_PWM_CH0 @@ -119,7 +131,7 @@ PWM 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -143,11 +155,11 @@ PWM 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_close(struct device *dev); + int device_close(struct device *dev); - dev 设备句柄 - return 错误码,0 表示关闭成功,其他表示错误 - + **device_control** ^^^^^^^^^^^^^^^^^^^ @@ -155,7 +167,7 @@ PWM 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_control(struct device *dev, int cmd, void *args); + int device_control(struct device *dev, int cmd, void *args); - dev 设备句柄 - cmd 设备控制命令 @@ -170,21 +182,23 @@ PWM 设备除了标准的控制命令,还具有自己特殊的控制命令。 ``args`` 根据不同的 ``cmd`` 传入不同,具体如下: -+------------------------------------------+-----------------+----------------------------+ -|cmd |args |description | -+==========================================+=================+============================+ -|DEVICE_CTRL_SET_INT |NULL |开启pwm传输完成中断 | -+------------------------------------------+-----------------+----------------------------+ -|DEVICE_CTRL_CLR_INT |NULL |关闭pwm传输完成中断 | -+------------------------------------------+-----------------+----------------------------+ -|DEVICE_CTRL_RESUME |NULL |恢复pwm通道 | -+------------------------------------------+-----------------+----------------------------+ -|DEVICE_CTRL_SUSPEND |NULL |挂起pwm通道 | -+------------------------------------------+-----------------+----------------------------+ -|DEVICE_CTRL_CONFIG |pwm_config_t |配置pwm通道频率和占空比 | -+------------------------------------------+-----------------+----------------------------+ -|DEIVCE_CTRL_PWM_IT_PULSE_COUNT_CONFIG |uint32_t* |配置中断计数阈值 | -+------------------------------------------+-----------------+----------------------------+ ++------------------------------------------+---------------------------+--------------------------+ +|cmd |args |description | ++==========================================+===========================+==========================+ +|DEVICE_CTRL_SET_INT |NULL |弃用 | ++------------------------------------------+---------------------------+--------------------------+ +|DEVICE_CTRL_CLR_INT |NULL |弃用 | ++------------------------------------------+---------------------------+--------------------------+ +|DEVICE_CTRL_RESUME |NULL |开启当前PWM通道 | ++------------------------------------------+---------------------------+--------------------------+ +|DEVICE_CTRL_SUSPEND |NULL |关闭当前PWM通道 | ++------------------------------------------+---------------------------+--------------------------+ +|DEIVCE_CTRL_PWM_FREQUENCE_CONFIG |uint32_t |配置当前PWM通道周期值 | ++------------------------------------------+---------------------------+--------------------------+ +|DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG |pwm_dutycycle_config_t |配置当前PWM通道占空比 | ++------------------------------------------+---------------------------+--------------------------+ +|DEIVCE_CTRL_PWM_IT_PULSE_COUNT_CONFIG |uint32_t |配置触发PWM中断周期值 | ++------------------------------------------+---------------------------+--------------------------+ **device_set_callback** ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -201,7 +215,7 @@ PWM 设备除了标准的控制命令,还具有自己特殊的控制命令。 - dev 设备句柄 - args 无用 - size 无用 - - event 中断事件类型 + - event 中断事件类型 PWM设备 ``event`` 类型如下 diff --git a/docs/development_guide/build/html/_sources/api_reference/api_spi.rst.txt b/docs/development_guide/build/html/_sources/api_reference/api_spi.rst.txt index d77bd239..0fe82fd3 100644 --- a/docs/development_guide/build/html/_sources/api_reference/api_spi.rst.txt +++ b/docs/development_guide/build/html/_sources/api_reference/api_spi.rst.txt @@ -22,7 +22,7 @@ SPI 设备结构体定义 ------------------------ .. code-block:: C - + typedef struct spi_device { struct device parent; @@ -84,7 +84,7 @@ SPI 设备结构体定义 ``datasize`` 提供以下类型 .. code-block:: C - + #define SPI_DATASIZE_8BIT 0 #define SPI_DATASIZE_16BIT 1 #define SPI_DATASIZE_24BIT 2 @@ -132,11 +132,11 @@ SPI 设备接口全部遵循标准设备驱动管理层提供的接口。 **spi_register** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``spi_register`` 用来注册一个 SPI 设备,在注册之前需要打开对应 SPI 设备的宏定义,例如定义宏 ``BSP_USING_SPI0`` 方可使用 SPI0 设备。注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 SPI 设备。 .. code-block:: C - + int spi_register(enum spi_index_type index, const char *name, uint16_t flag); - index 要注册的设备索引 @@ -146,7 +146,7 @@ SPI 设备接口全部遵循标准设备驱动管理层提供的接口。 ``index`` 用来选择 SPI 设备配置,一个 index 对应一个 SPI 设备配置,比如 ``SPI0_INDEX`` 对应 ``SPI0_CONFIG`` 配置,``index`` 有如下可选类型 .. code-block:: C - + enum spi_index_type { #ifdef BSP_USING_SPI0 @@ -162,7 +162,7 @@ SPI 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -186,11 +186,11 @@ SPI 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_close(struct device *dev); + int device_close(struct device *dev); - dev 设备句柄 - return 错误码,0 表示关闭成功,其他表示错误 - + **device_control** ^^^^^^^^^^^^^^^^^^^ @@ -198,7 +198,7 @@ SPI 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_control(struct device *dev, int cmd, void *args); + int device_control(struct device *dev, int cmd, void *args); - dev 设备句柄 - cmd 设备控制命令 @@ -246,7 +246,7 @@ SPI 设备除了标准的控制命令,还具有自己特殊的控制命令。 .. code-block:: C - int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); + int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); - dev 设备句柄 - pos 无作用 @@ -261,7 +261,7 @@ SPI 设备除了标准的控制命令,还具有自己特殊的控制命令。 .. code-block:: C - int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); + int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); - dev 设备句柄 - pos 无作用 @@ -284,7 +284,7 @@ SPI 设备除了标准的控制命令,还具有自己特殊的控制命令。 - dev 设备句柄 - args 接收发送缓冲区,数据类型为 uint8_t* - size 传输长度 - - event 中断事件类型 + - event 中断事件类型 SPI 设备 ``event`` 类型如下 diff --git a/docs/development_guide/build/html/_sources/api_reference/api_structure.rst.txt b/docs/development_guide/build/html/_sources/api_reference/api_structure.rst.txt index cbb00123..40eea4da 100644 --- a/docs/development_guide/build/html/_sources/api_reference/api_structure.rst.txt +++ b/docs/development_guide/build/html/_sources/api_reference/api_structure.rst.txt @@ -110,7 +110,7 @@ API 分层模型 .. code-block:: C - int device_register(struct device *dev, const char *name, uint16_t flag); + int device_register(struct device *dev, const char *name, uint16_t flag); - dev 设备句柄。 - name 设备名称。 @@ -133,7 +133,7 @@ API 分层模型 .. code-block:: C - int device_unregister(const char *name); + int device_unregister(const char *name); - dev 设备句柄 - name 要删除的设备名称 @@ -160,7 +160,7 @@ API 分层模型 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -184,11 +184,11 @@ API 分层模型 .. code-block:: C - int device_close(struct device *dev); + int device_close(struct device *dev); - dev 设备句柄 - return 错误码,0 表示关闭成功,其他表示错误 - + **device_control** ^^^^^^^^^^^^^^^^^^^ @@ -196,7 +196,7 @@ API 分层模型 .. code-block:: C - int device_control(struct device *dev, int cmd, void *args); + int device_control(struct device *dev, int cmd, void *args); - dev 设备句柄 - cmd 设备控制命令 @@ -230,7 +230,7 @@ API 分层模型 .. code-block:: C - int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); + int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); - dev 设备句柄 - pos 不同的设备 pos 的意义不同 @@ -245,7 +245,7 @@ API 分层模型 .. code-block:: C - int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); + int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); - dev 设备句柄 - pos 不同的设备 pos 的意义不同 diff --git a/docs/development_guide/build/html/_sources/api_reference/api_uart.rst.txt b/docs/development_guide/build/html/_sources/api_reference/api_uart.rst.txt index 8666481b..ac9785cd 100644 --- a/docs/development_guide/build/html/_sources/api_reference/api_uart.rst.txt +++ b/docs/development_guide/build/html/_sources/api_reference/api_uart.rst.txt @@ -20,7 +20,7 @@ UART 设备结构体定义 ------------------------ .. code-block:: C - + typedef struct uart_device { struct device parent; @@ -48,7 +48,7 @@ UART 设备结构体定义 .. code-block:: C - typedef enum + typedef enum { UART_DATA_LEN_5 = 0, /*!< Data length is 5 bits */ UART_DATA_LEN_6 = 1, /*!< Data length is 6 bits */ @@ -59,8 +59,8 @@ UART 设备结构体定义 ``stopbits`` 提供以下类型 .. code-block:: C - - typedef enum + + typedef enum { UART_STOP_ONE = 0, /*!< One stop bit */ UART_STOP_ONE_D_FIVE = 1, /*!< 1.5 stop bit */ @@ -70,8 +70,8 @@ UART 设备结构体定义 ``parity`` 提供以下类型 .. code-block:: C - - typedef enum + + typedef enum { UART_PAR_NONE = 0, /*!< No parity */ UART_PAR_ODD = 1, /*!< Parity bit is odd */ @@ -120,11 +120,11 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 **uart_register** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``uart_register`` 用来注册一个 UART 设备,在注册之前需要打开对应 UART 设备的宏定义。例如定义宏 ``BSP_USING_UART0`` 方可使用 ``UART0`` 设备,注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 ``UART0`` 设备。 .. code-block:: C - + int uart_register(enum uart_index_type index, const char *name, uint16_t flag); - index 要注册的设备索引 @@ -134,7 +134,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 ``index`` 用来选择 UART 设备配置,一个 index 对应一个 UART 设备配置,比如 ``UART0_INDEX`` 对应 ``UART0_CONFIG`` 配置,``index`` 有如下可选类型 .. code-block:: C - + enum uart_index_type { #ifdef BSP_USING_UART0 @@ -153,7 +153,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -177,11 +177,11 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_close(struct device *dev); + int device_close(struct device *dev); - dev 设备句柄 - return 错误码,0 表示关闭成功,其他表示错误 - + **device_control** ^^^^^^^^^^^^^^^^^^^ @@ -189,7 +189,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_control(struct device *dev, int cmd, void *args); + int device_control(struct device *dev, int cmd, void *args); - dev 设备句柄 - cmd 设备控制命令 @@ -209,9 +209,9 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 +---------------------------------+---------------------+------------------------------+ |cmd |args |description | +=================================+=====================+==============================+ -|DEVICE_CTRL_SET_INT |uart_it_type |开启spi设备中断 | +|DEVICE_CTRL_SET_INT |uart_it_type |开启uart设备中断 | +---------------------------------+---------------------+------------------------------+ -|DEVICE_CTRL_CLR_INT |uart_it_type |关闭spi设备中断 | +|DEVICE_CTRL_CLR_INT |uart_it_type |关闭uart设备中断 | +---------------------------------+---------------------+------------------------------+ |DEVICE_CTRL_CONFIG |uart_param_cfg_t* |修改串口配置 | +---------------------------------+---------------------+------------------------------+ @@ -241,7 +241,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); + int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); - dev 设备句柄 - pos 无作用 @@ -256,7 +256,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); + int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); - dev 设备句柄 - pos 无作用 @@ -279,7 +279,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 - dev 设备句柄 - args 接收发送缓冲区,数据类型为 uint8_t* - size 传输长度 - - event 中断事件类型 + - event 中断事件类型 串口设备 ``event`` 类型如下 diff --git a/docs/development_guide/build/html/_sources/get_started/Linux_quick_start_ubuntu.rst.txt b/docs/development_guide/build/html/_sources/get_started/Linux_quick_start_ubuntu.rst.txt index 367736cd..b200541e 100644 --- a/docs/development_guide/build/html/_sources/get_started/Linux_quick_start_ubuntu.rst.txt +++ b/docs/development_guide/build/html/_sources/get_started/Linux_quick_start_ubuntu.rst.txt @@ -25,7 +25,7 @@ Linux OR WSL 环境开发指南 $ wget -c https://dev.bouffalolab.com/media/upload/download/riscv64-elf-x86_64-20210120.tar.gz $ mkdir -p riscv64-elf-20210120 $ tar -zxvf riscv64-elf-x86_64-20210120.tar.gz -C riscv64-elf-20210120 - $ sudo cp ~/riscv64-elf-20210120 /usr/bin + $ sudo cp -rf ~/riscv64-elf-20210120 /usr/bin $ echo "export PATH=\"$PATH:/usr/bin/riscv64-elf-20210120/bin\"" >> ~/.bashrc $ source ~/.bashrc @@ -39,9 +39,9 @@ Linux OR WSL 环境开发指南 $ sudo apt update $ sudo apt install make $ cd ~ - $ wget -c https://cmake.org/files/v3.19/cmake-3.19.3-Linux-x86_64.tar.gz + $ wget -c https://cmake.org/files/v3.19/cmake-3.19.3-Linux-x86_64.tar.gz $ tar -zxvf cmake-3.19.3-Linux-x86_64.tar.gz - $ sudo cp ~/cmake-3.19.3-Linux-x86_64 /usr/bin + $ sudo cp -rf ~/cmake-3.19.3-Linux-x86_64 /usr/bin $ echo "export PATH=\"$PATH:/usr/bin/cmake-3.19.3-Linux-x86_64/bin\"" >> ~/.bashrc $ source ~/.bashrc @@ -119,7 +119,7 @@ Linux OR WSL 环境开发指南 :linenos: $ sudo apt install picocom # 若已经安装请忽略 - $ picocom -b 2000000 /dev/ttyUSB0 + $ picocom -b 2000000 /dev/ttyUSB0 # 注意你的可用串口号 (如使用 Sipeed RV-debugger) - 按一下开发板上的 ``rst`` 按键,即可在串口终端中看到 ``hello world!`` diff --git a/docs/development_guide/build/html/_sources/get_started/Windows_quick_start_cdk.rst.txt b/docs/development_guide/build/html/_sources/get_started/Windows_quick_start_cdk.rst.txt index e739371a..684a971b 100644 --- a/docs/development_guide/build/html/_sources/get_started/Windows_quick_start_cdk.rst.txt +++ b/docs/development_guide/build/html/_sources/get_started/Windows_quick_start_cdk.rst.txt @@ -6,15 +6,15 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 本文档介绍了如何在 Windows 下使用 `平头哥半导体 `_ 开发的 CDK 集成开发环境, 来完成博流 BL702 系列 MCU 的相关软件开发工作。 -关于剑池 CDK ,这是一款由平头哥半导体开发打造的集成开发环境。它拥有和传统 MCU 开发环境十分近似的操作和设置,旨在不改变用户开发习惯的基础上,全面接入云端开发资源,结合图形化的 OSTracer、Profiling 等调试分析工具,加速用户产品开发。 +关于剑池 CDK ,这是一款由平头哥半导体开发打造的集成开发环境。它拥有和传统 MCU 开发环境十分近似的操作和设置,旨在不改变用户开发习惯的基础上,全面接入云端开发资源,结合图形化的 OSTracer、Profiling 等调试分析工具,加速用户产品开发 需要的软硬件环境 ----------------------------- - 剑池 CDK 软件 -- 一根 USB Type-A 数据线 -- 一个 CK-Link 仿真器 +- 一根 USB Type-A 数据线、一根 Type-C 数据线 +- 一个 CK-Link 仿真器 or 一个 Sipeed RV-Debugger Plus 调试器 - 一个 USB-TTL 串口模块 - 杜邦线若干 @@ -22,9 +22,9 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 下载剑池 CDK 软件安装包 ----------------------------- -- `剑池CDK `_ 软件安装可以从平头哥半导体 OCC 官网获取到。 +- `剑池CDK `_ 软件安装可以从平头哥半导体 OCC 官网获取到 -- 下载完成后,解压缩,双击 ``setup.exe``,按照其提示,完成软件安装即可。 +- 下载完成后,解压缩,双击 ``setup.exe``,按照其提示,完成软件安装即可 下载 bl_mcu_sdk 软件开发包 @@ -33,7 +33,7 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 - 从开源社区下载 bl_mcu_sdk 软件开发包。 - 可以使用 ``git clone`` 或者直接 ``download`` 的方式下 SDK - - 使用 ``git clone`` 前请确保已正确安装 ``git``,打开支持 ``git`` 的终端输入以下命令即可获取最新的 SDK。 + - 使用 ``git clone`` 前请确保已正确安装 ``git``,打开支持 ``git`` 的终端输入以下命令即可获取最新的 SDK .. code-block:: bash :linenos: @@ -47,16 +47,17 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 - 具体开发板的连接, 请参考 :ref:`connect_hardware` 部分 - 请确保开发板被正确设置后再进行下面的步骤 - + 测试 Hello World 工程 ------------------------------ +**使用 Sipeed RV-Debugger Plus 调试工程时请按照下面的步骤进行:** + 打开 Hello World ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- 获取到 SDK 后,进入 sdk 中的 ``examples/hellowd/helloworld/cdk`` 目录下,双击 ``helloworld.cdkproj``,即可打开 ``Helloworld`` 工程。 - +- 获取到 SDK 后,进入 sdk 中的 ``examples/hellowd/helloworld/cdk`` 目录下,双击 ``helloworld.cdkproj``,即可打开 ``Helloworld`` 工程 编译 Hello World ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,6 +67,78 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 helloworld.cdkproj +- 在活动工程下拉菜单选择 ``OpenOCD_Debug`` 工程,由于 Sipeed RV-Debugger Plus 是使用 OpenOCD 调试的,所以本教程基于 ``OpenOCD_Debug`` 工程; +- 如 Sipeed RV-Debugger Plus 没有正确安装驱动,请参考 :ref:`sipeed_rv_debugger_plus` 部分,设置好驱动程序,在进行下面的步骤 + +- 在 CDK 工具栏中,点击编译图标即可编译工程 + + - 点击 ``1`` 处 图标 ``Build Project`` 即可编译当前选中的工程 + - 点击 ``2`` 处 图标 ``Clean Project`` 即可清除上次编译的结果 + - 点击 ``3`` 处 图标 ``Flash Download`` 即可将编译好的代码下载到芯片中 (**使用 OpenOCD Debug 不能使用 Flash 下载功能**) + - 点击 ``4`` 处 图标 ``Start/Stop Debug`` 即可进行 debug 的相关操作 + - 也可以在 ``Project`` 中,右击工程名称,通过右击菜单中的选项对项目进行编译等操作 + + +烧写 Hello World +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- 在 CDK 中使用 OpenOCD 模式的调试方式时,暂不支持直接使用 CDK 相关 flash 工具下载代码,所以请使用 BL Dev Cube 工具进行程序烧写,烧写代码请参考 :ref:`bl_dev_cube` 部分进行 +- 代码烧写完成后使用 CDK 进行 Debug + +运行 Hello World +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- 从 CDK 的菜单栏 ``View->Serial Pane``,打开串口面板,在打开的 ``Serial Pane`` 中右击,进行串口设置,选择你对应的串口号和波特率 + +.. figure:: img/cdk4.png +.. figure:: img/cdk3.png + :alt: + + CDK Serial Pane setting + +- 按下板子上的 ``RST`` 按键,即可在串口中看到代码的运行结果 + +.. figure:: img/cdk6.png + :alt: + + HelloWorld! + + +调试 Hello World +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- 点击工具栏上方的 ``Start/Stop Debugger`` 按钮,进入 debug 界面,如下图所示 + +.. figure:: img/cdk10.png + :alt: + + Debug HelloWorld! + +- 在 debug 界面下,左侧的 ``Register`` 窗口中,可以查看 ``CPU`` 内部寄存器数据;右侧的 ``Peripherals`` 外设面板中, + 可以查看相应外设寄存器数据,外设的选择可以在顶部菜单栏的 ``Peripherals->System Viewer`` 选择; + 点击上方工具栏中的相关调试按钮可以进行断点设置、单步调试、指令单步和全速运行等操作。 + 当然这些操作都有相应的快捷键和快捷设置方法,详情请参考 ``CDK Help``,这里就不作过多介绍了。 + +- 我们点击单步运行按钮,运行代码,即可看到指示光标移动到下一句代码,同时可以看到串口面板中显示了我们输出的 ``Hello World!`` + + +**使用 CK-Link 调试工程时请按照下面的步骤进行:** + +打开 Hello World +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- 获取到 SDK 后,进入 sdk 中的 ``examples/hellowd/helloworld/cdk`` 目录下,双击 ``helloworld.cdkproj``,即可打开 ``Helloworld`` 工程 + +编译 Hello World +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. figure:: img/cdk1.png + :alt: + + helloworld.cdkproj + +- 在活动工程下拉菜单可以选择 ``CK_Link_Debug`` 或者 ``OpenOCD_Debug`` 工程,本教程基于 ``CK_Link_Debug`` 工程 + - 在 CDK 工具栏中,点击编译图标即可编译工程 - 点击 ``1`` 处 图标 ``Build Project`` 即可编译当前选中的工程 @@ -94,7 +167,7 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 :alt: CDK Project Setting - + - 点击 ``Project View`` 中的项目设置按钮,打开 ``Project Setting`` 窗口,或者通过右击 ``Project`` 名称中右击菜单栏中打开 - 在打开的 ``Project Setting`` 窗口中,选择 ``Flash`` 标签,配置需要的 Flash 算法 @@ -107,7 +180,7 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 - 在 ``Flash`` 标签中,点击 ``Add`` 按纽,在打开的列表中选择 ``bl70x_flash`` 算法,点击 ``Add`` 添加到工程中,``Flash`` 标签下的其他设置,如图所示: - 点击 OK 后,如配置正确,点击 ``Flash Download`` 即可将编译好的代码下载到芯片中 - + .. figure:: img/cdk5.png :alt: @@ -155,7 +228,7 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 点击上方工具栏中的相关调试按钮可以进行断点设置、单步调试、指令单步和全速运行等操作。 当然这些操作都有相应的快捷键和快捷设置方法,详情请参考 ``CDK Help``,这里就不作过多介绍了。 -- 我们点击单步运行按钮,运行代码,即可看到指示光标移动到下一句代码,同时可以看到串口面板中显示了我们输出的 ``Hello World!`` +- 我们点击单步运行按钮,运行代码,即可看到指示光标移动到下一句代码,同时可以看到串口面板中显示了我们输出的 ``Hello World!`` .. figure:: img/cdk11.png :alt: diff --git a/docs/development_guide/build/html/_sources/get_started/Windows_quick_start_eclipse.rst.txt b/docs/development_guide/build/html/_sources/get_started/Windows_quick_start_eclipse.rst.txt index f0e506d8..b48d9d3a 100644 --- a/docs/development_guide/build/html/_sources/get_started/Windows_quick_start_eclipse.rst.txt +++ b/docs/development_guide/build/html/_sources/get_started/Windows_quick_start_eclipse.rst.txt @@ -144,7 +144,7 @@ Windows 下使用 Eclipse 开发指南 - 点击 eclipse 工具栏中的 ``Debug`` 按钮,进入 debug 配置窗口 - 选择 ``GDB SEGGER J-Link Debugging->Jlink_bl_mcu_sdk`` Debug 配置,在 ``C/C++ Application:`` 选项中选择需要调试的 ``.elf`` 文件 -- 先点击 ``Apply`` 后,在点击 ``Debug`` 即可进行 ``Debug`` +- 先点击 ``Apply`` 后,在点击 ``Debug`` 即可进行 ``Debug`` .. figure:: img/pic14.png :alt: @@ -153,7 +153,7 @@ Windows 下使用 Eclipse 开发指南 .. figure:: img/pic15.png :alt: - + Eclipse Debugging diff --git a/docs/development_guide/build/html/_sources/get_started/bl_dev_cube.rst.txt b/docs/development_guide/build/html/_sources/get_started/bl_dev_cube.rst.txt index 19c8e7b9..c239cd67 100644 --- a/docs/development_guide/build/html/_sources/get_started/bl_dev_cube.rst.txt +++ b/docs/development_guide/build/html/_sources/get_started/bl_dev_cube.rst.txt @@ -59,17 +59,17 @@ BLDevCube 烧录工具指南 - 硬件连接需要更改为支持 Openocd 的调试器连接(本教程以 Sipeed RV Debugger 为例): - 1. 首先将 RV 调试器连接到电脑的 USB 接口,打开设备管理器,会发现调试器被识别为两个串口(注:不是开发板上的串口) - + .. figure:: img/sipeed_rv_debugger_1.png - 2. 从 sipeed 下载 ``zadig-2.4`` 替换驱动程序。下载地址:`http://dl.sipeed.com/MAIX/tools/sipeed-rv-debugger/zadig-2.4.exe `_ - 3. 下载好双击打开 ``zadig-2.4.exe``,选择 Options 勾选 List All Devices. - + .. figure:: img/sipeed_rv_debugger_3.png - + - 4. 找到 JTAG Debugger(Interface 0),然后选择替换的驱动为 WinUSB 点击 Replace Driver 替换 - 5. 再次打开设备管理器, 看到其中一个串口被替换成通用串行总线设备就说明安装成功 - + .. figure:: img/sipeed_rv_debugger_2.png - 6.将调试器的 JTAG 引脚与开发板的 JTAG 引脚连接起来 diff --git a/docs/development_guide/build/html/_sources/get_started/connecting_hardware.rst.txt b/docs/development_guide/build/html/_sources/get_started/connecting_hardware.rst.txt index 4c6abc98..7887e77d 100644 --- a/docs/development_guide/build/html/_sources/get_started/connecting_hardware.rst.txt +++ b/docs/development_guide/build/html/_sources/get_started/connecting_hardware.rst.txt @@ -20,8 +20,8 @@ BL706_IOT 开发板 bl706-iot board CK-Link ------------------------------- JTAG_TDI <--> TDI - JTAG_TDO <--> TDO - JTAG_TCK <--> TCK + JTAG_TDO <--> TDO + JTAG_TCK <--> TCK JTAG_TMS <--> TMS VDD33 <--> VREF GND <--> GND @@ -45,8 +45,8 @@ BL706_IOT 开发板 bl706-iot board j-link ------------------------------- JTAG_TDI <--> TDI - JTAG_TDO <--> TDO - JTAG_TCK <--> TCK + JTAG_TDO <--> TDO + JTAG_TCK <--> TCK JTAG_TMS <--> TMS VDD33 <--> VTref GND <--> GND @@ -82,16 +82,73 @@ BL706_IOT 开发板 - 烧写方法同上 -BL702_AVB 开发板 +BL706_AVB 开发板 -------------------------- +.. important:: BL706_AVB 开发板有多个引脚存在复用情况,请仔细检查所需功能引脚是否被复用了;FUNC1:「Default: PIX; Connect: I2S/JTAG」,FUNC2:「Default: I2S; Connect: SPI」; **如果需要调试,请务必记得将 FUNC1 跳帽连接** + +使用 Sipeed RV-Debugger Plus 烧写、调试连接方法 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- 将 BL706_AVB 开发板先供电 +- 将 RV-Debugger Plus 调试器连接到电脑 USB 口,如没有正确安装驱动,请参考 :ref:`sipeed_rv_debugger_plus` 部分,设置好驱动程序,在进行下面的步骤 +- 将调试器和 BL706_AVB 开发板使用排线连接起来(如下图所示) + +.. important:: 使用调试功能是一定要将 FUNC1 跳帽连接,否则引脚被复用其他功能,不能使用 JTAG 功能;串口功能可以正常使用 + +.. figure:: img/bl706_avb_rv_debugger_plus.png + :alt: + + RV-Debugger connect bl706_avb board + 使用 CK-Link 烧写、调试连接方法 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- ``TO DO`` +- 将 CK-Link USB 接口使用合适的 USB 数据线正确连接到 PC 主机 +- 将 bl706_avb 开发板的 FUNC1 跳帽短接 +- 将 ``HD8`` 组的引脚使用排线引到转接板 +- 将转接板的标准 ``JTAG`` 引脚使用杜邦线与 ``CK-Link`` 对应的 ``JTAG`` 引脚连接起来 +- 若没有使用 CK-Link 给开发板供电,需要给开发板单独供电 + +:: + + bl706-avb board CK-Link + ------------------------------- + JTAG_TDI <--> TDI + JTAG_TDO <--> TDO + JTAG_TCK <--> TCK + JTAG_TMS <--> TMS + VDD33 <--> VREF + GND <--> GND + + +.. figure:: img/bl706_avb_ck_link.png + :alt: + + ck_link connect bl706_avb board 使用串口烧写程序连接方法 ^^^^^^^^^^^^^^^^^^^^^^^^^^ -- ``TO DO`` +- 使用串口烧写前,请确保正确安装了 ``Bouffalo Lab Dev Cube`` 或命令行烧写工具 + + - 使用 ``Type-C USB`` 数据线 or ``Mini USB`` 数据线连接到开发板上对应的 ``Type-C`` 接口 or ``Mini`` 接口上。 + - 按下开发板上的 ``Boot`` 键,不要释放 + - 按下开发板上的 ``RST`` 键,此时已经进入 ``Boot ROM``,可以释放两个按键 + - 这时就可以从 ``Bouffalo Lab Dev Cube`` 中看到相应的串口 ``COM`` 号,如没有出现,请点击 ``Refresh`` 按钮刷新一下 + + +- 如没有合适的数据线,也可以使用一些常见的 ``USB-TTL`` 模块,连接到开发板的 ``UART0`` 端口进行烧写。 ``UART0`` 在 ``HD12`` 组上,连接方法如下: + +- 如果使用 Sipeed RV-Debugger Plus 通过排线连接了 BL706_AVB 开发板,则也可以使用 Sipeed RV Debugger Plus 的串口 + +:: + + USB-TTL BL706_AVB + ---------------------- + TXD <--> RX0 + RXD <--> TX0 + GND <--> GND + +- diff --git a/docs/development_guide/build/html/_sources/get_started/get_started.rst.txt b/docs/development_guide/build/html/_sources/get_started/get_started.rst.txt index 40441314..c2b5afa4 100644 --- a/docs/development_guide/build/html/_sources/get_started/get_started.rst.txt +++ b/docs/development_guide/build/html/_sources/get_started/get_started.rst.txt @@ -4,30 +4,30 @@ 硬件环境准备 ----------------------------- -- 一块 BL702 系列 MCU 的开发板: +- 至少有一块 BL702 系列 MCU 的开发板: - - BL706_IOT 开发板, or + - BL706_IOT 开发板 - BL706_AVB 开发板 BL706_Iot 开发板如下图所示 .. figure:: img/bl702_iot.png :alt: - + BL706_IoT BL706_AVB 开发板如下图所示 .. figure:: img/bl706_avb.png :alt: - + BL706_AVB - 一个支持标准 JTAG 功能的调试器,下面几款调试器中选择一款与开发环境适合即可: - CK-Link 仿真器 - Jlink V11 仿真器 - - Sipeed USB-JTAG/TTL 调试器 + - Sipeed RV-Debugger Plus 调试器 - Bouffalo Lab Debugger 调试器 - 一台 PC 主机(运行 Windows 或者 Linux 系统) @@ -35,9 +35,66 @@ BL706_AVB 开发板如下图所示 软件环境准备 -------------------------------- -为了更好的进行 BL702 系列 MCU 的开发,建议您应当具备以下开发环境: +为了更好的进行 BL702 系列 MCU 的开发,建议您应当至少具备以下一种开发环境: -- Windows 使用 `CDK `_ 环境开发 (建议 Windows 7 以上版本。) ,or -- `Windows `_ 使用 Eclipse 环境开发 (建议 Windows 7 以上版本。) ,or +- Windows 使用 `CDK `_ 环境开发 (建议 Windows 7 以上版本) +- `Windows `_ 使用 Eclipse 环境开发 (建议 Windows 7 以上版本) - `Linux `_ (建议使用 Ubuntu 18 以上的 LTS 版本) + +.. _sipeed_rv_debugger_plus: + +调试器驱动安装设置 +----------------------------- + +- 本节主要介绍 **Sipeed RV-Debugger Plus** 调试器的驱动安装设置,若使用 **CK-Link** 或者 **J-Link** 无需阅读本节内容 + +.. figure:: img/sipeed_rv_debugger_plus.png + :alt: + + Sipeed RV-Debugger plus + +**Windows** + +- Sipeed RV-Debugger Plus 调试器在 Windows 系统中所以时我们需要将驱动更换为 ``Win USB`` 驱动 + + - 1. 首先,将调试器 Type-C USB 接口使用 USB 数据线连接到 PC 主机,打开 PC 的设备管理器,在端口一栏可以看到调试器被识别为两个串口(*注:不是开发板上的串口*),或者在 ``通用串行总线控制器`` 看到 ``USB Serial Converter A`` 和 ``USB Serial Converter B`` + + .. figure:: img/sipeed_rv_debugger_1.png + + .. figure:: img/sipeed_rv_debugger_4.png + + - 2. 从 sipeed 网站下载 ``zadig-2.4`` 替换驱动程序。下载地址:`http://dl.sipeed.com/MAIX/tools/sipeed-rv-debugger/zadig-2.4.exe `_ + - 3. 下载好双击打开 ``zadig-2.4.exe``,选择 Options 勾选 List All Devices. + + .. figure:: img/sipeed_rv_debugger_3.png + + - 4. 找到 JTAG Debugger(Interface 0),然后选择替换的驱动为 ``WinUSB`` 点击 Replace Driver 替换 + - 5. 再次打开设备管理器, 看到其中一个串口被替换成通用串行总线设备就说明安装成功 + + .. figure:: img/sipeed_rv_debugger_2.png + + - 6. 到这里 Sipeed RV-Debugger Plus 的设备驱动就更换好了,接下来就可以愉快的玩耍啦~ + + +**可能出现的问题:** + +.. caution:: 1. 调试器接上时没有出现两个串口,调试器上有一个 LED 常亮,那么应该是进入了 Boot 模式。请将调试器断电重新上电,注意先不要将调试器连接到目标板;调试器上电后,正常情况下两个 LED 灯会闪烁一下熄灭;此时再看一下任务管理器中的设备是否正确。 + +.. caution:: 2. 在设备管理器中没有看到任何串口,但是在``通用串行总线控制器``中看到 ``USB Serial Converter A`` 和 ``USB Serial Converter B``;遇到这种情况,请到 `FTDI 官网 `_ 下载与系统匹配的驱动,将 ``USB Serial Converter B`` 重新安装为串口;``USB Serial Converter A`` 也即 Interface 0,使用 ``zadig-2.4.exe`` 替换为 WinUSB 驱动。 + +**Linux** + +- 安装 Openocd 及其需要的依赖项 + +.. code-block:: bash + + $ apt install openocd libusb-dev libftdi-dev libhidapi-dev + +- 重新插拔调试器使修改生效 +- 打开 Terminal,在终端中输入 lsusb 命令,即可看到如下信息的设备 + +.. code-block::bash + + $ Bus 001 Device 003: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC + diff --git a/docs/development_guide/build/html/_sources/index.rst.txt b/docs/development_guide/build/html/_sources/index.rst.txt index 03591fe4..8fa042ab 100644 --- a/docs/development_guide/build/html/_sources/index.rst.txt +++ b/docs/development_guide/build/html/_sources/index.rst.txt @@ -26,7 +26,7 @@ BL MCU SDK 将为您提供博流 BL70X 系列 MCU 开发的全方位支持。 - + .. toctree:: :maxdepth: 1 :caption: API 手册 @@ -42,28 +42,31 @@ BL MCU SDK 将为您提供博流 BL70X 系列 MCU 开发的全方位支持。 api_reference/api_spi api_reference/api_adc api_reference/api_dac + .. api_reference/api_ble + + - .. toctree:: :maxdepth: 1 :caption: 基础外设例程 :numbered: - samples/basic samples/blink_demo - samples/basic samples/button_demo - samples/basic samples/breath_pwm_demo - samples/basic samples/uart_loopback_demo - samples/basic samples/mtimer_demo - samples/basic samples/dma_m2m_demo - samples/basic samples/i2c_eeprom_demo - samples/basic samples/spi_lcd_demo - samples/basic samples/adc_key_demo + samples/basic samples/gpio/index + samples/basic samples/uart/index + samples/basic samples/pwm/index + samples/basic samples/mtimer/index + samples/basic samples/dma/index + samples/basic samples/spi/index + samples/basic samples/i2c/index + samples/basic samples/adc/index + + .. toctree:: :maxdepth: 1 :caption: 进阶例程 :numbered: - + samples/advance samples/shell_demo samples/advance samples/fatfs_demo samples/advance samples/lowpower_demo diff --git a/docs/development_guide/build/html/_sources/samples/advance samples/ble_scan_demo.rst.txt b/docs/development_guide/build/html/_sources/samples/advance samples/ble_scan_demo.rst.txt index 15c0b16b..922974af 100644 --- a/docs/development_guide/build/html/_sources/samples/advance samples/ble_scan_demo.rst.txt +++ b/docs/development_guide/build/html/_sources/samples/advance samples/ble_scan_demo.rst.txt @@ -48,7 +48,7 @@ BLE client 软件实现 uint8_t buf[20] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; while(1) { - k_sem_take(&write_data_poll_sem, K_FOREVER); + k_sem_take(&write_data_poll_sem, K_FOREVER); BT_WARN("ble_write_data\r\n"); // Send data to server error = bt_gatt_write_without_response(ble_tp_conn,char_hdl.tp_wr_hdl,buf,20,0); @@ -75,7 +75,7 @@ BLE server 软件实现 :linenos: int ble_start_adv(void) - { + { struct bt_le_adv_param adv_param = { //options:3, connectable undirected, adv one time .options = 3, \ @@ -83,7 +83,7 @@ BLE server 软件实现 .interval_max = BT_GAP_ADV_FAST_INT_MAX_3, \ }; - + char *adv_name = "BL_TEST_01"; // This name must be the same as adv_name in ble_central uint8_t data[1] = {(BT_LE_AD_LIMITED | BT_LE_AD_NO_BREDR)}; uint8_t data_uuid[2] = {0x12, 0x18};//0x1812 @@ -119,8 +119,8 @@ BLE server 软件实现 char data[244] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09}; k_sem_give(¬ify_poll_sem); while(1) - { - k_sem_take(¬ify_poll_sem, K_FOREVER); + { + k_sem_take(¬ify_poll_sem, K_FOREVER); //send data to client err = bt_gatt_notify(ble_tp_conn, get_attr(BT_CHAR_BLE_TP_NOT_ATTR_VAL_INDEX), data, (tx_mtu_size - 3)); BT_WARN("ble tp send notify : %d\n", err); @@ -168,7 +168,7 @@ BLE server 软件实现 .. figure:: img/ble_server.png :alt: - + - **手机连接 bl702** .. figure:: img/phone_connect.jpg diff --git a/docs/development_guide/build/html/_sources/samples/advance samples/boot2_iap_info.rst.txt b/docs/development_guide/build/html/_sources/samples/advance samples/boot2_iap_info.rst.txt index d1b01764..929138af 100644 --- a/docs/development_guide/build/html/_sources/samples/advance samples/boot2_iap_info.rst.txt +++ b/docs/development_guide/build/html/_sources/samples/advance samples/boot2_iap_info.rst.txt @@ -25,4 +25,4 @@ bl_mcu_sdk 开源了 boot2_iap 的软件源码,用户可以到 examples/boot2_ 实验现象 ----------------------------- -使用 Dev Cube 完成 IAP 功能的具体步骤,请参阅 `DevCube用户手册 `_ 章节。 \ No newline at end of file +使用 Dev Cube 完成 IAP 功能的具体步骤,请参阅 `DevCube用户手册 `_ 章节。 \ No newline at end of file diff --git a/docs/development_guide/build/html/_sources/samples/advance samples/lowpower_demo.rst.txt b/docs/development_guide/build/html/_sources/samples/advance samples/lowpower_demo.rst.txt index 40d62cec..9833a92d 100644 --- a/docs/development_guide/build/html/_sources/samples/advance samples/lowpower_demo.rst.txt +++ b/docs/development_guide/build/html/_sources/samples/advance samples/lowpower_demo.rst.txt @@ -5,13 +5,13 @@ LowPower 低功耗评估 ------------------------ 博流系列芯片拥有丰富的低功耗特性,以适配不同的低功耗应用场合。为了方便用户快速的评测使用 bl 系列 MCU 低功耗性能 bl_mcu_sdk 提供了一套抽象的低功耗接口,将低功耗等级分为四个等级,分别为 - + 1. Running : Running 为 CPU 正常运行时的功耗,由客户应用代码执行的功能决定功耗。 - + 2. WFI :WFI 模式,CPU 的 clock 处于被 Gating 状态,CPU 停止运行,当用户退出WFI模式的时候程序将会继续运行。 - + 3. PDS : PDS 模式,关闭了芯片上大多数电源域,同时关闭了 CPU,和 CPU 处于同一个电源域的 ITCM,DTCM 等 RAM 不可使用,只有 64K 的 OCTAM 可以保存数据,可以通过内部 RTC 进行唤醒,或者使用 GPIO 引脚(在 GPIO 电源域没有关闭的情况下)唤醒。 - + 4. HBN : HBN 模式,关闭了芯片上绝大多数电源域,关闭了 CPU 以及 64K OCRAM,只有位于 AON 域的 4K RAM 可以保存数据,可以通过内部 RTC 进行唤醒,或者使用特定的唤醒引脚(位于 AON 域的引脚)唤醒。 @@ -59,7 +59,7 @@ bl_mcu_sdk 提供了一个简单的低功耗参考示例(bl_mcu_sdk examples/pow - 电流表 - 一台 PC 主机(运行 Windows 或者 Linux 系统) - TTL 转 USB - + 如下图所示,将电流表串联进入 bl706 模组的供电线路,通过 PC 端的串口调试助手软件,下发不同的低功耗指令,使得 bl706 进入对应的低功耗模式 观察电流表示值,完成评估。 diff --git a/docs/development_guide/build/html/_sources/samples/advance samples/shell_demo.rst.txt b/docs/development_guide/build/html/_sources/samples/advance samples/shell_demo.rst.txt index 4142f385..6ec8fee3 100644 --- a/docs/development_guide/build/html/_sources/samples/advance samples/shell_demo.rst.txt +++ b/docs/development_guide/build/html/_sources/samples/advance samples/shell_demo.rst.txt @@ -1,32 +1,198 @@ SHELL 命令行调试 ==================== -为方便用户使用 pc 或者其他控制器对开发板进行功能的调试(非仿真器调试),这里提供了 shell 命令行组件,类似于在 linux 下进行命令行操作。用户在 PC 端或者其他控制端进行命令的发送,通过串口、usb、以太网、蓝牙、wifi等方式,将数据发送给开发板的 shell 中,shell 会读取接收的命令进行解析并对已经注册的内部函数扫描,扫描到与之匹配的函数以后,执行匹配的函数,并实时返回传入的键值和函数执行的结果给 pc or 控制端。其中需要注意,控制器端需要发送标准键盘的键值。 +为方便用户使用 pc 或者其他控制器对开发板进行功能的调试(非仿真器调试),我们为用户提供了 shell 命令行组件,类似于在 linux 下进行命令行操作。用户在 PC 端或者其他控制端进行命令的发送,通过串口、usb、以太网、蓝牙、wifi等方式,将数据发送给开发板的 shell 中,shell 会读取接收的命令进行解析并对已经注册的内部函数扫描,扫描到与之匹配的函数以后,执行匹配的函数,并实时返回传入的键值和函数执行的结果给 pc or 控制端。其中需要注意,控制器端需要发送标准键盘的键值。 本 demo 将演示如何使用 **shell** 通过串口进行命令行调试。 +本 shell 组件有以下功能: + +- 支持标准键盘字符控制 +- 支持命令自动补全 +- 支持上下键查看历史命令 +- 支持左右键修改命令 +- 支持文件系统、网络系统调试 + 准备工具 ----------------------- -- pc控制端使用串口终端软件:xshell或者mobaxterm +- pc控制端使用串口终端软件:xshell 或者 mobaxterm - 连接介质:usb转串口 or 网络 or usb +硬件连接 +----------------------------- + +本 demo 基于 BL706_IOT 开发板,连接方式如下 + +:: + + GPIO function GPIO pin + ---------------------------------- + UART0_TX <--> GPIO14 + UART0_RX <--> GPIO15 + + 软件实现 ------------------------- -串口中使用 SHELL +shell 移植到串口 ^^^^^^^^^^^^^^^^^^^^ -BLE 中使用 SHELL -^^^^^^^^^^^^^^^^^^^^ +- 软件代码见 ``examples/shell`` + +.. code-block:: C + :linenos: + + #define BSP_UART_CLOCK_SOURCE ROOT_CLOCK_SOURCE_PLL_96M + #define BSP_UART_CLOCK_DIV 0 + +- 配置 ``UART`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` + +.. code-block:: C + :linenos: + + #define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX + #define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX + +- 配置 ``UART`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` + +.. code-block:: C + :linenos: + + #define BSP_USING_UART0 + + #if defined(BSP_USING_UART0) + #ifndef UART0_CONFIG + #define UART0_CONFIG \ + { \ + .id = 0, \ + .baudrate = 2000000,\ + .databits = UART_DATA_LEN_8, \ + .stopbits = UART_STOP_ONE, \ + .parity = UART_PAR_NONE, \ + .fifo_threshold = 1, \ + } + #endif + #endif + +- 使能 ``BSP_USING_UART0`` 并配置 ``UART`` 设备配置,见 ``bsp/board/bl706_iot/peripheral_config.h`` + +.. code-block:: C + :linenos: + + bflb_platform_init(); + +- 在 ``bflb_platform_init`` 函数中,我们已经注册并且打开了一个调试用的串口设备,给用户实现一个 ``MSG`` 的基本功能用作打印输出报文。具体实现如下 + +.. code-block:: C + :linenos: + + uart_register(board_get_debug_uart_index(), "debug_log", DEVICE_OFLAG_RDWR); + struct device *uart = device_find("debug_log"); + + if (uart) + { + device_open(uart, DEVICE_OFLAG_STREAM_TX | DEVICE_OFLAG_INT_RX); + device_set_callback(uart, NULL); + device_control(uart, DEVICE_CTRL_CLR_INT, (void *)(UART_RX_FIFO_IT)); + } + +- 首先调用 ``uart_register`` 函数注册 ``UART`` 设备,当前注册 ``UART0`` +- 然后通过 ``find`` 函数找到设备对应的句柄,保存于 ``uart`` 句柄中 +- 最后使用 ``device_open`` 以轮询发送和中断接收来打开 ``uart`` 设备,默认关闭中断并且不注册接收中断回调函数 + +.. code-block:: C + :linenos: + + struct device *uart = device_find("debug_log"); + if (uart) { + device_set_callback(uart, shell_irq_callback); + device_control(uart, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT)); + } + +- 通过 ``device_set_callback`` 函数,为 ``UART0`` 注册接收中断服务函数。通过 ``device_control`` 函数打开 ``UART_RX_FIFO_IT`` 中断 + +.. code-block:: C + :linenos: + + void shell_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state) + { + uint8_t data; + if (state == UART_EVENT_RX_FIFO) { + data = *(uint8_t *)args; + shell_handler(data); + } + } + +- 中断回调函数中,判断 ``state`` 是否是 ``UART_EVENT_RX_FIFO``,是的话就将接收的字节传入 ``shell_handler`` 函数。 + + +.. code-block:: C + :linenos: + + shell_init(); + +- 调用 ``shell_init`` 初始化 shell 组件。 -以太网中使用 SHELL -^^^^^^^^^^^^^^^^^^^^ SHELL 命令注册 ^^^^^^^^^^^^^^^^^^^^ +shell 命令注册使用以下两个宏 + +- **SHELL_CMD_EXPORT** + +``SHELL_CMD_EXPORT`` 有两个参数,``command`` 代表需要注册的函数名,pc 或者控制器将发送 ``command`` 对设备进行命令控制,desc`` 是对该注册函数的描述, + +.. code-block:: C + :linenos: + + void hellowd() + { + MSG("hello World\r\n"); + } + SHELL_CMD_EXPORT(hellowd, hellowd test) + +- **SHELL_CMD_EXPORT_ALIAS** + +``SHELL_CMD_EXPORT_ALIAS`` 有三个参数,``command`` 代表需要注册的函数名,``alias`` 是对该注册函数名重命名,pc 或者控制器将发送 ``alias`` 对设备进行命令控制,``desc`` 是对该注册函数的描述, + +.. code-block:: C + :linenos: + + void hellowd() + { + MSG("hello World\r\n"); + } + SHELL_CMD_EXPORT_ALIAS(hellowd, hellwd,hellowd test) + + 编译和烧录 ----------------------------- +- **CDK 编译** + + 打开项目中提供的工程文件:shell.cdkproj + + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 + +- **命令行编译** + +.. code-block:: bash + :linenos: + + $ cd /bl_mcu_sdk + $ make BOARD=bl706_iot APP=shell SUPPORT_SHELL=y + +- **烧录** + + 详见 :ref:`bl_dev_cube` + + 实验现象 ----------------------------- + +.. figure:: img/shell_demo.gif + :alt: + +shell test + diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/adc_key_demo.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/adc/adc_key_demo.rst.txt similarity index 95% rename from docs/development_guide/build/html/_sources/samples/basic samples/adc_key_demo.rst.txt rename to docs/development_guide/build/html/_sources/samples/basic samples/adc/adc_key_demo.rst.txt index 10a4b30a..bc5cbd5a 100644 --- a/docs/development_guide/build/html/_sources/samples/basic samples/adc_key_demo.rst.txt +++ b/docs/development_guide/build/html/_sources/samples/basic samples/adc/adc_key_demo.rst.txt @@ -31,14 +31,14 @@ ADC - 按键检测电压 #define BSP_ADC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK #define BSP_ADC_CLOCK_DIV 0 -- 配置 ``ADC`` 设备时钟源,见 ``bsp/board/bl706_avb/clock_config.h`` +- 配置 ``ADC`` 设备时钟源,见 ``bsp/board/bl706_avb/clock_config.h`` .. code-block:: C :linenos: #define CONFIG_GPIO18_FUNC GPIO_FUN_ADC -- 配置 ``ADC`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` +- 配置 ``ADC`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` .. code-block:: C :linenos: @@ -78,7 +78,7 @@ ADC - 按键检测电压 ADC_DEV(adc_key)->continuous_conv_mode = ENABLE; device_open(adc_key, DEVICE_OFLAG_STREAM_RX); device_control(adc_key,DEVICE_CTRL_ADC_CHANNEL_CONFIG,&adc_channel_cfg); - + }else{ MSG("device open failed\r\n"); } @@ -111,7 +111,7 @@ ADC - 按键检测电压 - **CDK工具编译** 打开项目中提供的工程文件:adc_key.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/adc/index.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/adc/index.rst.txt new file mode 100644 index 00000000..bc04aa5b --- /dev/null +++ b/docs/development_guide/build/html/_sources/samples/basic samples/adc/index.rst.txt @@ -0,0 +1,9 @@ +======================= +ADC 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + ADC - 按键检测电压 \ No newline at end of file diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/dma_m2m_demo.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/dma/dma_m2m_demo.rst.txt similarity index 95% rename from docs/development_guide/build/html/_sources/samples/basic samples/dma_m2m_demo.rst.txt rename to docs/development_guide/build/html/_sources/samples/basic samples/dma/dma_m2m_demo.rst.txt index fc41cae1..9be58654 100644 --- a/docs/development_guide/build/html/_sources/samples/basic samples/dma_m2m_demo.rst.txt +++ b/docs/development_guide/build/html/_sources/samples/basic samples/dma/dma_m2m_demo.rst.txt @@ -56,7 +56,7 @@ DMA - RAM间数据搬运 .. code-block:: C :linenos: - dma_reload(dma,(uint32_t)dma_src_buffer,(uint32_t)dma_dst_buffer,8000); + dma_reload(dma,(uint32_t)dma_src_buffer,(uint32_t)dma_dst_buffer,8000); dma_channel_start(dma); - 调用 ``dma_reload`` 函数对dma 通道0的配置进行补充,``DMA0_CH0_CONFIG`` 中已经补充了一部分配置,这边主要补充源数据地址和目标数据地址以及传输总长度 @@ -92,7 +92,7 @@ DMA - RAM间数据搬运 - **CDK 编译** 打开项目中提供的工程文件:dma_m2m.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/dma/index.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/dma/index.rst.txt new file mode 100644 index 00000000..8cb8e35f --- /dev/null +++ b/docs/development_guide/build/html/_sources/samples/basic samples/dma/index.rst.txt @@ -0,0 +1,9 @@ +======================= +DMA 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + DMA - RAM间数据搬运 \ No newline at end of file diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/blink_demo.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/gpio/blink_demo.rst.txt similarity index 100% rename from docs/development_guide/build/html/_sources/samples/basic samples/blink_demo.rst.txt rename to docs/development_guide/build/html/_sources/samples/basic samples/gpio/blink_demo.rst.txt diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/button_demo.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/gpio/button_demo.rst.txt similarity index 95% rename from docs/development_guide/build/html/_sources/samples/basic samples/button_demo.rst.txt rename to docs/development_guide/build/html/_sources/samples/basic samples/gpio/button_demo.rst.txt index cff8dd8f..7abe7bbf 100644 --- a/docs/development_guide/build/html/_sources/samples/basic samples/button_demo.rst.txt +++ b/docs/development_guide/build/html/_sources/samples/basic samples/gpio/button_demo.rst.txt @@ -42,7 +42,7 @@ GPIO 中断 - 按键检测 - **CDK 编译** 打开项目中提供的工程文件:gpio_int.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/gpio/index.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/gpio/index.rst.txt new file mode 100644 index 00000000..d5f7805f --- /dev/null +++ b/docs/development_guide/build/html/_sources/samples/basic samples/gpio/index.rst.txt @@ -0,0 +1,10 @@ +======================= +GPIO 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + GPIO 输出 - 流水灯 + GPIO 中断 - 流水灯 \ No newline at end of file diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/i2c_eeprom_demo.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/i2c/i2c_eeprom_demo.rst.txt similarity index 94% rename from docs/development_guide/build/html/_sources/samples/basic samples/i2c_eeprom_demo.rst.txt rename to docs/development_guide/build/html/_sources/samples/basic samples/i2c/i2c_eeprom_demo.rst.txt index 05767cd8..8df3042a 100644 --- a/docs/development_guide/build/html/_sources/samples/basic samples/i2c_eeprom_demo.rst.txt +++ b/docs/development_guide/build/html/_sources/samples/basic samples/i2c/i2c_eeprom_demo.rst.txt @@ -25,7 +25,7 @@ I2C - AT24CXX 读写 #define BSP_I2C_CLOCK_SOURCE ROOT_CLOCK_SOURCE_BCLK #define BSP_I2C_CLOCK_DIV 0 -- 配置 ``I2C`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` +- 配置 ``I2C`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` .. code-block:: C :linenos: @@ -33,7 +33,7 @@ I2C - AT24CXX 读写 #define CONFIG_GPIO11_FUNC GPIO_FUN_I2C #define CONFIG_GPIO16_FUNC GPIO_FUN_I2C -- 配置 ``I2C`` 设备复用引脚,见 ``bsp/board/bl706_iot/peripheral_config.h`` +- 配置 ``I2C`` 设备复用引脚,见 ``bsp/board/bl706_iot/peripheral_config.h`` .. code-block:: C :linenos: @@ -97,7 +97,7 @@ I2C - AT24CXX 读写 - **CDK 编译** 打开项目中提供的工程文件:i2c_at24cxx.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/i2c/index.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/i2c/index.rst.txt new file mode 100644 index 00000000..c5a8d721 --- /dev/null +++ b/docs/development_guide/build/html/_sources/samples/basic samples/i2c/index.rst.txt @@ -0,0 +1,9 @@ +======================= +I2C 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + I2C - AT24CXX 读写 \ No newline at end of file diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/mtimer/index.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/mtimer/index.rst.txt new file mode 100644 index 00000000..e97a26b9 --- /dev/null +++ b/docs/development_guide/build/html/_sources/samples/basic samples/mtimer/index.rst.txt @@ -0,0 +1,9 @@ +======================= +MTIMER 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + MTIMER - 系统定时器 \ No newline at end of file diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/mtimer_demo.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/mtimer/mtimer_demo.rst.txt similarity index 88% rename from docs/development_guide/build/html/_sources/samples/basic samples/mtimer_demo.rst.txt rename to docs/development_guide/build/html/_sources/samples/basic samples/mtimer/mtimer_demo.rst.txt index 9d5fb128..22e81093 100644 --- a/docs/development_guide/build/html/_sources/samples/basic samples/mtimer_demo.rst.txt +++ b/docs/development_guide/build/html/_sources/samples/basic samples/mtimer/mtimer_demo.rst.txt @@ -1,4 +1,4 @@ -MTIMER - 内核定时器 +MTIMER - 系统定时器 ==================== 本 demo 基于 risc-v 内核自带的一个 64 位定时器(MTIMER)编写。本 demo 可以为后面 os tick 提供参考。 @@ -11,7 +11,7 @@ MTIMER - 内核定时器 ----------------------------- - 软件代码见 ``examples/systick`` - + .. note:: ``mtimer`` 时钟默认经过分频以后为 1M,方便后面使用,减少计算时间。 .. code-block:: C @@ -34,7 +34,7 @@ MTIMER - 内核定时器 - **CDK 编译** 打开项目中提供的工程文件:systick.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** @@ -44,7 +44,7 @@ MTIMER - 内核定时器 $ cd /bl_mcu_sdk $ make BOARD=bl706_iot APP=systick - + - **烧录** 详见 :ref:`bl_dev_cube` @@ -52,4 +52,4 @@ MTIMER - 内核定时器 实验现象 ----------------------------- -``tick`` 值每秒自增 1 并通过串口打印。 \ No newline at end of file +``tick`` 值每秒自增 1 并通过串口打印。 \ No newline at end of file diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/pwm/index.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/pwm/index.rst.txt new file mode 100644 index 00000000..3b66b54f --- /dev/null +++ b/docs/development_guide/build/html/_sources/samples/basic samples/pwm/index.rst.txt @@ -0,0 +1,10 @@ +======================= +PWM 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + PWM - 呼吸灯 + PWM - 驱动步进电机 \ No newline at end of file diff --git a/docs/development_guide/source/samples/basic samples/breath_pwm_demo.rst b/docs/development_guide/build/html/_sources/samples/basic samples/pwm/pwm_breath_demo.rst.txt similarity index 62% rename from docs/development_guide/source/samples/basic samples/breath_pwm_demo.rst rename to docs/development_guide/build/html/_sources/samples/basic samples/pwm/pwm_breath_demo.rst.txt index b91ca37f..6ad05a0c 100644 --- a/docs/development_guide/source/samples/basic samples/breath_pwm_demo.rst +++ b/docs/development_guide/build/html/_sources/samples/basic samples/pwm/pwm_breath_demo.rst.txt @@ -1,7 +1,7 @@ PWM - 呼吸灯 ==================== - 本demo基于PWM外设轮询模式编写。 + 本 demo 基于 PWM 外设轮询模式编写。 硬件连接 ----------------------------- @@ -22,12 +22,20 @@ PWM - 呼吸灯 - 软件代码见 ``examples/pwm/pwm_breath_led`` +.. code-block:: C + :linenos: + + #define BSP_PWM_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK + #define BSP_PWM_CLOCK_DIV 1 + +- 配置 ``PWM`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` + .. code-block:: C :linenos: #define CONFIG_GPIO22_FUNC GPIO_FUN_PWM -- 配置 ``PWM`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` +- 配置 ``PWM`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` .. code-block:: C :linenos: @@ -51,12 +59,14 @@ PWM - 呼吸灯 .. code-block:: C :linenos: - pwm_register(PWM_CH2_INDEX, "led_breath", DEVICE_OFLAG_RDWR); + pwm_register(PWM_CH2_INDEX, "led_breath", DEVICE_OFLAG_RDWR); struct device *led_breath = device_find("led_breath"); - if (led_breath) - { + if (led_breath) { + PWM_DEV(led_breath)->period = 32; //frequence = 32M/1/32 = 1Mhz + PWM_DEV(led_breath)->threshold_low = 16; + PWM_DEV(led_breath)->threshold_high = 32; device_open(led_breath, DEVICE_OFLAG_STREAM_TX); pwm_channel_start(led_breath); } @@ -64,19 +74,23 @@ PWM - 呼吸灯 - 首先调用 ``pwm_register`` 函数注册 ``PWM`` 设备的一个通道,当前注册 ``PWM_CH2`` - 然后通过 ``find`` 函数找到设备对应的句柄,保存于 ``led_breath`` 句柄中 +- 设置 ``PWM_CH2`` 的频率为 1Mhz,占空比为50% - 使用 ``device_open`` 以轮询模式来打开 ``led_breath`` 设备 .. code-block:: C :linenos: - pwm_config_t pwm_cfg = { - 1000000, - 0, - }; - - device_control(led_breath, DEVICE_CTRL_CONFIG, &pwm_cfg); + for (pwm_cfg.threshold_high = 0; pwm_cfg.threshold_high <= 32; pwm_cfg.threshold_high++) { + device_control(led_breath, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg); + bflb_platform_delay_ms(50); + } -- 使用 ``device_contorl`` 函数,配合 ``DEVICE_CTRL_CONFIG`` 指令,可以修改当前 PWM 通道的频率和占空比。 + for (pwm_cfg.threshold_high = 32; 0 <= pwm_cfg.threshold_high && pwm_cfg.threshold_high <= 32; pwm_cfg.threshold_high--) { + device_control(led_breath, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg); + bflb_platform_delay_ms(50); + } + +- 使用 ``device_contorl`` 函数,配合 ``DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG`` 指令,可以修改当前 PWM 通道的占空比。 编译和烧录 ----------------------------- @@ -84,7 +98,7 @@ PWM - 呼吸灯 - **CDK 编译** 打开项目中提供的工程文件:pwm_breath_led.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** @@ -104,7 +118,7 @@ PWM - 呼吸灯 ----------------------------- -.. figure:: img/pwm_demo.gif +.. figure:: img/pwm_demo.gif :alt: pwm breath led! diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/pwm/pwm_step_motor.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/pwm/pwm_step_motor.rst.txt new file mode 100644 index 00000000..356ce0ba --- /dev/null +++ b/docs/development_guide/build/html/_sources/samples/basic samples/pwm/pwm_step_motor.rst.txt @@ -0,0 +1,281 @@ +PWM - 驱动步进电机 +==================== + +步进电机是一种将电脉冲转化为角位移的执行机构。当步进驱动器接收到一个脉冲信号,它就驱动步进电机按设定的方向转动一个固定的角度(及步进角)。可以通过控制脉冲个来控制角位移量,从而达到准确定位的目的;同时可以通过控制脉冲频率来控制电机转动的速度和加速度,从而达到调速的目的。 + +本 demo 采用步进电机 28BYJ48 型四相八拍电机,使用 ULN2003 芯片驱动,电压为 DC5V—DC12V。当对步进电机施加一系列连续不断的控制脉冲时,它可以连续不断地转动。每一个脉冲信号对应步进电机的某一相或两相绕组的通电状态改变一次,也就对应转子转过一定的角度(一个步距角)。当通电状态的改变完成一个循环时,转子转过一个齿距。 + +.. figure:: img/step_motor.png + :alt: + + 28BYJ48 + +.. figure:: img/uln2003.png + :alt: + + ULN2003 + +这个步进电机内部有个真正的步进马达转子,每一个脉冲能使这个真正的转子转动5.625°,看下图的数据表格中的减速比是1:64,意思是这个真正的步进马达转子转动64周才能让输出轴转动1周,因此下图的表格中步距角度才写的是5.625°/64,表明的意思是一个脉冲可以让输出轴转动5.625°/64的角度。所以要让马达转一周(360°), 则需要360/5.625*64=4096个脉冲。 +脉冲(或拍)的数量决定转动的角度,单位时间内脉冲(或拍)的数量决定转动的速度 + +.. figure:: img/step_motor_info.png + :alt: + +四相步进电机可以在不同的通电方式下运行,常见的通电方式有如下三种: + +- 一相励磁:单(单相绕组通电)四拍(A+,B+,A-,B-......) + +.. figure:: img/pwm_step_motor1.png + :alt: + +- 二相励磁:双(双相绕组通电)四拍(A+B+,B+A-,A-B-,B-A+......) + +.. figure:: img/pwm_step_motor2.png + :alt: + +- 一二相励磁:八拍(A+B+,B+,B+A-,A-,A-B-,B-,B-A+,A+......) + +.. figure:: img/pwm_step_motor3.png + :alt: + + +硬件连接 +----------------------------- + +本 demo 基于BL706_IOT开发板,连接方式如下 + +:: + + GPIO function GPIO pin + ---------------------------------- + PWM_CH0 <--> GPIO10 + PWM_CH1 <--> GPIO11 + PWM_CH2 <--> GPIO12 + PWM_CH3 <--> GPIO3 + +.. figure:: img/pwm_step_motor.png + :alt: + + 参考电路 + +软件实现 +----------------------------- + +- 软件代码见 ``examples/pwm/pwm_step_motor`` + +.. code-block:: C + :linenos: + + #define BSP_PWM_CLOCK_SOURCE ROOT_CLOCK_SOURCE_RC_32K + #define BSP_PWM_CLOCK_DIV 32 + +- 配置 ``PWM`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` + +.. code-block:: C + :linenos: + + #define CONFIG_GPIO3_FUNC GPIO_FUN_PWM + #define CONFIG_GPIO10_FUNC GPIO_FUN_PWM + #define CONFIG_GPIO11_FUNC GPIO_FUN_PWM + #define CONFIG_GPIO12_FUNC GPIO_FUN_PWM + +- 配置 ``PWM`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` + +.. code-block:: C + :linenos: + + #define BSP_USING_PWM_CH0 + #define BSP_USING_PWM_CH1 + #define BSP_USING_PWM_CH2 + #define BSP_USING_PWM_CH3 + + #if defined(BSP_USING_PWM_CH0) + #ifndef PWM_CH0_CONFIG + #define PWM_CH0_CONFIG \ + { \ + .ch = 0, \ + .polarity_invert_mode = DISABLE, \ + .period = 0, \ + .threshold_low = 0, \ + .threshold_high = 0, \ + .it_pulse_count = 0, \ + } + #endif + #endif + + #if defined(BSP_USING_PWM_CH1) + #ifndef PWM_CH1_CONFIG + #define PWM_CH1_CONFIG \ + { \ + .ch = 1, \ + .polarity_invert_mode = DISABLE, \ + .period = 0, \ + .threshold_low = 0, \ + .threshold_high = 0, \ + .it_pulse_count = 0, \ + } + #endif + #endif + + #if defined(BSP_USING_PWM_CH2) + #ifndef PWM_CH2_CONFIG + #define PWM_CH2_CONFIG \ + { \ + .ch = 2, \ + .polarity_invert_mode = DISABLE, \ + .period = 0, \ + .threshold_low = 0, \ + .threshold_high = 0, \ + .it_pulse_count = 0, \ + } + #endif + #endif + + #if defined(BSP_USING_PWM_CH3) + #ifndef PWM_CH3_CONFIG + #define PWM_CH3_CONFIG \ + { \ + .ch = 3, \ + .polarity_invert_mode = DISABLE, \ + .period = 0, \ + .threshold_low = 0, \ + .threshold_high = 0, \ + .it_pulse_count = 0, \ + } + #endif + #endif + + +- 使能 ``BSP_USING_PWM_CH0``, ``BSP_USING_PWM_CH1`` , ``BSP_USING_PWM_CH2``, ``BSP_USING_PWM_CH3`` 并配置 ``PWM`` 设备配置,见 ``bsp/board/bl706_iot/peripheral_config.h`` + +.. code-block:: C + :linenos: + + pwm_register(PWM_CH0_INDEX, "motor_ch0", DEVICE_OFLAG_RDWR); + pwm_register(PWM_CH1_INDEX, "motor_ch1", DEVICE_OFLAG_RDWR); + pwm_register(PWM_CH2_INDEX, "motor_ch2", DEVICE_OFLAG_RDWR); + pwm_register(PWM_CH3_INDEX, "motor_ch3", DEVICE_OFLAG_RDWR); + + motor_ch0 = device_find("motor_ch0"); + motor_ch1 = device_find("motor_ch1"); + motor_ch2 = device_find("motor_ch2"); + motor_ch3 = device_find("motor_ch3"); + + if (motor_ch0) { + PWM_DEV(motor_ch0)->period = 8; //frequence = 32K/160/8 = 25hz + PWM_DEV(motor_ch0)->threshold_low = 2; + PWM_DEV(motor_ch0)->threshold_high = 7; + PWM_DEV(motor_ch0)->polarity_invert_mode = ENABLE; + device_open(motor_ch0, DEVICE_OFLAG_STREAM_TX); + } + if (motor_ch1) { + PWM_DEV(motor_ch1)->period = 8; //frequence = 32K/160/8 = 25hz + PWM_DEV(motor_ch1)->threshold_low = 1; + PWM_DEV(motor_ch1)->threshold_high = 4; + device_open(motor_ch1, DEVICE_OFLAG_STREAM_TX); + } + if (motor_ch2) { + PWM_DEV(motor_ch2)->period = 8; //frequence = 32K/160/8 = 25hz + PWM_DEV(motor_ch2)->threshold_low = 3; + PWM_DEV(motor_ch2)->threshold_high = 6; + device_open(motor_ch2, DEVICE_OFLAG_STREAM_TX); + } + if (motor_ch3) { + PWM_DEV(motor_ch3)->period = 8; //frequence = 32K/160/8 = 25hz + PWM_DEV(motor_ch3)->threshold_low = 5; + PWM_DEV(motor_ch3)->threshold_high = 8; + device_open(motor_ch3, DEVICE_OFLAG_STREAM_TX); + } + pwm_channel_start(motor_ch0); + pwm_channel_start(motor_ch1); + pwm_channel_start(motor_ch2); + pwm_channel_start(motor_ch3); + + +- 首先调用 ``pwm_register`` 函数注册 ``PWM`` 设备的一个通道,当前注册 PWM 通道0/1/2/3 +- 然后通过 ``find`` 函数找到设备对应的句柄,保存于4个句柄中 +- 设置 4个通道 的频率为 125hz,占空比为37.5% +- 使用 ``device_open`` 以轮询模式来打开 4个通道 + +.. code-block:: C + :linenos: + + enum motor_dir_type { + CW, + CCW, + STOP + }; + + void motor_set_dir(enum motor_dir_type dir) + { + pwm_dutycycle_config_t pwm_cfg[4]; + + if (dir == CW) { + pwm_cfg[0].threshold_low = 2; + pwm_cfg[0].threshold_high = 7; + pwm_cfg[1].threshold_low = 1; + pwm_cfg[1].threshold_high = 4; + pwm_cfg[2].threshold_low = 3; + pwm_cfg[2].threshold_high = 6; + pwm_cfg[3].threshold_low = 5; + pwm_cfg[3].threshold_high = 8; + } + + else if (dir == CCW) { + pwm_cfg[0].threshold_low = 2; + pwm_cfg[0].threshold_high = 7; + pwm_cfg[1].threshold_low = 5; + pwm_cfg[1].threshold_high = 8; + pwm_cfg[2].threshold_low = 3; + pwm_cfg[2].threshold_high = 6; + pwm_cfg[3].threshold_low = 1; + pwm_cfg[3].threshold_high = 4; + } else if (dir == STOP) { + pwm_cfg[0].threshold_low = 0; + pwm_cfg[0].threshold_high = 0; + pwm_cfg[1].threshold_low = 0; + pwm_cfg[1].threshold_high = 0; + pwm_cfg[2].threshold_low = 0; + pwm_cfg[2].threshold_high = 0; + pwm_cfg[3].threshold_low = 0; + pwm_cfg[3].threshold_high = 0; + } + device_control(motor_ch0, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg[0]); + device_control(motor_ch1, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg[1]); + device_control(motor_ch2, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg[2]); + device_control(motor_ch3, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg[3]); + } + +- 使用 ``device_contorl`` 函数,配合 ``DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG`` 指令,修改4个 PWM 通道的的高低阈值。 + +.. note:: 该函数的功能主要用于切换步进电机的方向 + +编译和烧录 +----------------------------- + +- **CDK 编译** + + 打开项目中提供的工程文件:pwm_step_motor.cdkproj + + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 + +- **命令行编译** + +.. code-block:: bash + :linenos: + + $ cd /bl_mcu_sdk + $ make BOARD=bl706_iot APP=pwm_step_motor + +- **烧录** + + 详见 :ref:`bl_dev_cube` + + +实验现象 +----------------------------- + +.. figure:: img/pwm_step_motor.gif + :alt: + + diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/spi/index.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/spi/index.rst.txt new file mode 100644 index 00000000..4645a2ab --- /dev/null +++ b/docs/development_guide/build/html/_sources/samples/basic samples/spi/index.rst.txt @@ -0,0 +1,9 @@ +======================= +SPI 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + SPI - TFT LCD 显示 \ No newline at end of file diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/spi_lcd_demo.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/spi/spi_lcd_demo.rst.txt similarity index 93% rename from docs/development_guide/build/html/_sources/samples/basic samples/spi_lcd_demo.rst.txt rename to docs/development_guide/build/html/_sources/samples/basic samples/spi/spi_lcd_demo.rst.txt index ec8a487d..c2ebe373 100644 --- a/docs/development_guide/build/html/_sources/samples/basic samples/spi_lcd_demo.rst.txt +++ b/docs/development_guide/build/html/_sources/samples/basic samples/spi/spi_lcd_demo.rst.txt @@ -28,7 +28,7 @@ SPI - TFT LCD 显示 #define BSP_SPI_CLOCK_SOURCE ROOT_CLOCK_SOURCE_BCLK #define BSP_SPI_CLOCK_DIV 0 -- 配置 ``SPI`` 设备时钟源,见 ``bsp/board/bl706_avb/clock_config.h`` +- 配置 ``SPI`` 设备时钟源,见 ``bsp/board/bl706_avb/clock_config.h`` .. code-block:: C :linenos: @@ -37,7 +37,7 @@ SPI - TFT LCD 显示 #define CONFIG_GPIO20_FUNC GPIO_FUN_SPI #define CONFIG_GPIO21_FUNC GPIO_FUN_SPI -- 配置 ``SPI`` 设备复用引脚,见 ``bsp/board/bl706_avb/pinmux_config.h`` +- 配置 ``SPI`` 设备复用引脚,见 ``bsp/board/bl706_avb/pinmux_config.h`` .. note:: ``bsp/board/bl706_avb/pinmux_config.h`` 当前给所有的示例demo使用,所以,需要先选定 ``PINMUX_SELECT`` 为 ``PINMUX_LVGL``,开启其中一个 demo @@ -89,7 +89,7 @@ SPI - TFT LCD 显示 } - 配置 ``LCD_CS`` 和 ``LCD_DC`` 引脚为输出模式并拉高 -- 调用 ``spi_register`` 函数注册 ``SPI`` 设备,当前注册 ``SPI0`` +- 调用 ``spi_register`` 函数注册 ``SPI`` 设备,当前注册 ``SPI0`` - 然后通过 ``find`` 函数找到设备对应的句柄,保存于 ``spi0`` 句柄中 - 最后使用 ``device_open`` 以轮询发送模式来打开 ``spi0`` 设备 @@ -128,7 +128,7 @@ SPI - TFT LCD 显示 - **CDK 编译** 打开项目中提供的工程文件:spi_lcd.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** @@ -146,7 +146,7 @@ SPI - TFT LCD 显示 实验现象 ----------------------------- -.. figure:: img/spi_lcd.png +.. figure:: img/spi_lcd.png :alt: spi display! diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/uart/index.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/uart/index.rst.txt new file mode 100644 index 00000000..6f4e10e8 --- /dev/null +++ b/docs/development_guide/build/html/_sources/samples/basic samples/uart/index.rst.txt @@ -0,0 +1,9 @@ +======================= +UART 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + UART - 数据自收发 \ No newline at end of file diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/uart_loopback_demo.rst.txt b/docs/development_guide/build/html/_sources/samples/basic samples/uart/uart_loopback_demo.rst.txt similarity index 86% rename from docs/development_guide/build/html/_sources/samples/basic samples/uart_loopback_demo.rst.txt rename to docs/development_guide/build/html/_sources/samples/basic samples/uart/uart_loopback_demo.rst.txt index b50dd86c..dc31158b 100644 --- a/docs/development_guide/build/html/_sources/samples/basic samples/uart_loopback_demo.rst.txt +++ b/docs/development_guide/build/html/_sources/samples/basic samples/uart/uart_loopback_demo.rst.txt @@ -26,7 +26,7 @@ UART - 数据自收发 #define BSP_UART_CLOCK_SOURCE ROOT_CLOCK_SOURCE_PLL_96M #define BSP_UART_CLOCK_DIV 0 -- 配置 ``UART`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` +- 配置 ``UART`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` .. code-block:: C :linenos: @@ -34,7 +34,7 @@ UART - 数据自收发 #define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX #define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX -- 配置 ``UART`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` +- 配置 ``UART`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` .. code-block:: C :linenos: @@ -73,13 +73,13 @@ UART - 数据自收发 if (uart) { device_open(uart, DEVICE_OFLAG_STREAM_TX | DEVICE_OFLAG_INT_RX); - device_set_callback(uart, uart_iqr_callback); - device_control(uart, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT)); + device_set_callback(uart, NULL); + device_control(uart, DEVICE_CTRL_CLR_INT, (void *)(UART_RX_FIFO_IT)); } - 首先调用 ``uart_register`` 函数注册 ``UART`` 设备,当前注册 ``UART0`` - 然后通过 ``find`` 函数找到设备对应的句柄,保存于 ``uart`` 句柄中 -- 最后使用 ``device_open`` 以轮询发送和中断接收来打开 ``uart`` 设备,调用 ``device_set_callback`` 注册一个 ``UART0`` 中断回调函数,调用 ``device_control`` 开启 ``UART RX FIFO`` 中断 +- 最后使用 ``device_open`` 以轮询发送和中断接收来打开 ``uart`` 设备,默认关闭中断并且不注册接收中断回调函数 .. code-block:: C :linenos: @@ -90,7 +90,7 @@ UART - 数据自收发 device_control(uart, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT|UART_RTO_IT)); } -- 通过 ``device_set_callback`` 函数,注册用户指定的中断服务函数。通过 ``device_control`` 函数打开 ``RX FIFO`` 和 ``RTO`` 中断 +- 通过 ``device_set_callback`` 函数,注册用户指定的``UART0`` 接收中断服务函数。通过 ``device_control`` 函数打开 ``RX_FIFO`` 和 ``RTO`` 中断 .. code-block:: C :linenos: @@ -107,9 +107,9 @@ UART - 数据自收发 } } - + - 此函数是示例的中断服务函数,作用是将接受到的数据原封不动的发送出去。 - + - ``state`` 会返回 ``UART`` 设备的中断类型 - ``args`` 包含了返回数据指针 - ``size`` 包含返回数据的长度 @@ -124,7 +124,7 @@ UART - 数据自收发 - **CDK 编译** 打开项目中提供的工程文件:uart_echo.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** diff --git a/docs/development_guide/build/html/api_reference/api_adc.html b/docs/development_guide/build/html/api_reference/api_adc.html index 9185179e..6b862e69 100644 --- a/docs/development_guide/build/html/api_reference/api_adc.html +++ b/docs/development_guide/build/html/api_reference/api_adc.html @@ -111,22 +111,29 @@
  • 9.1. 简介
  • 9.2. ADC 设备结构体定义
  • 9.3. ADC 设备参数配置表
  • -
  • 9.4. ADC 设备接口
  • +
  • 9.4. ADC 设备接口 +
  • 10. DAC 设备
  • 基础外设例程

    进阶例程

      @@ -206,15 +213,261 @@

      9. ADC 设备

      9.1. 简介

      +

      ADC (Analog-to-digital Converter) 是用于将模拟形式的连续信号转换为数字形式的离散信号的一类设备,他可以将外围电路传感器产生的模拟信号转化为机器可识别的数字信号。 +博流系列MCU中的ADC设备具有以下特性

      +
        +
      • 可以选择 12/14/16 bits转换结果输出

      • +
      • ADC最大工作时钟为2MHZ

      • +
      • 支持2.0V,3.2V可选内部参考电压

      • +
      • 支持DMA将转换结果搬运到内存

      • +
      • 支持单次单通道转换、连续单通道转换、单次多通道转换和连续多通道转换模式四种模式

      • +
      • 支持单端与差分两种输入模式

      • +
      • 12路外部模拟通道

      • +
      • 2路DAC内部通道

      • +
      • 1路VBAT/2通道

      • +

      9.2. ADC 设备结构体定义

      +
      typedef struct adc_device {
      +    struct device parent;
      +    adc_clk_div_t clk_div;
      +    adc_vref_t vref;
      +    bool continuous_conv_mode;
      +    bool differential_mode;
      +    adc_data_width_t data_width;
      +    adc_fifo_threshold_t fifo_threshold;
      +    adc_pga_gain_t gain;
      +} adc_device_t;
      +
      +
      +
        +
      • parent 继承父类属性

      • +
      • clk_div ADC模块时钟内部分频

      • +
      • vref 参考电压选择 2.0/3.2V可选

      • +
      • continuous_conv_mode 是否选择为连续模式,若为连续模式,则一次adc_start操作,ADC连续工作,直到adc_stop。否则,每adc_start一次,adc仅转换一次结果。

      • +
      • differential_mode 选择是否为差分模式,若为差分模式,则可以测量负电压。

      • +
      • data_width 测量宽度选择,ADC实际精度为12bits,但是通过OSR多次取平均可以达到14bits/16bits的精度,注意,当选择更高的数据宽度后,频率会因为取平均而下降。详情可参考枚举信息。

      • +
      • fifo_threshold 此参数影响DMA搬运阈值以及ADC FIFO中断阈值

      • +
      • gain ADC对输入信号的增益选择

      • +
      • 其他待补充

      • +

      9.3. ADC 设备参数配置表

      +

      每一个 ADC 设备都有一个参数配置宏,宏定义位于 bsp/board/xxx 目录下 peripheral_config.h 文件,变量定义位于 hal_adc.c 中,因此无需用户自己定义变量。当用户打开对应设备的宏,该设备的配置才生效。例如打开宏 BSP_USING_ADC0 即生效,同时 ADC 设备就可以进行注册和使用了。

      +
      /*参数配置宏*/
      +#if defined(BSP_USING_ADC0)
      +#ifndef ADC0_CONFIG
      +#define ADC0_CONFIG                                        \
      +    {                                                      \
      +        .clk_div = ADC_CLOCK_DIV_32,                       \
      +        .vref = ADC_VREF_3P2V,                             \
      +        .continuous_conv_mode = DISABLE,                   \
      +        .differential_mode = DISABLE,                      \
      +        .data_width = ADC_DATA_WIDTH_16B_WITH_256_AVERAGE, \
      +        .fifo_threshold = ADC_FIFO_THRESHOLD_1BYTE,        \
      +        .gain = ADC_GAIN_1                                 \
      +    }
      +#endif
      +#endif
      +
      +/*变量定义*/
      +static adc_device_t adcx_device[ADC_MAX_INDEX] = {
      +#ifdef BSP_USING_ADC0
      +    ADC0_CONFIG,
      +#endif
      +};
      +
      +
      +
      +

      注解

      +

      上述配置可以通过 ADC_DEV(dev)->xxx 进行修改,只能在调用 device_open 之前使用。

      +

      9.4. ADC 设备接口

      +

      ADC 设备接口全部遵循标准设备驱动管理层提供的接口。

      +
      +

      9.4.1. ADC_register

      +

      adc_register 用来注册一个 ADC 设备,在注册之前需要打开对应 ADC 设备的宏定义。例如定义宏 BSP_USING_ADC0 方可使用 ADC0 设备,注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 ADC0 设备。

      +
      int ADC_register(enum ADC_index_type index, const char *name, uint16_t flag);
      +
      +
      +
        +
      • index 要注册的设备索引

      • +
      • name 为注册的设备命名

      • +
      • flag 默认可读可写属性

      • +
      +

      index 用来选择 ADC 设备配置,一个 index 对应一个 ADC 设备配置,比如 ADC0_INDEX 对应 ADC0_CONFIG 配置,index 有如下可选类型

      +
      enum ADC_index_type
      +{
      +#ifdef BSP_USING_ADC0
      +    ADC0_INDEX,
      +#endif
      +    ADC_MAX_INDEX
      +};
      +
      +
      +
      +
      +

      9.4.2. device_open

      +

      device_open 用于 ADC 设备的打开,oflag 表示以何种方式打开。

      +
      int device_open(struct device *dev, uint16_t oflag);
      +
      +
      +
        +
      • dev 设备句柄

      • +
      • oflag 设备的打开方式

      • +
      • return 错误码,0 表示打开成功,其他表示错误

      • +
      +

      oflag 可以写入以下参数:

      +
      #define DEVICE_OFLAG_STREAM_TX  0x001 /* 设备以轮训发送模式打开 */
      +#define DEVICE_OFLAG_STREAM_RX  0x002 /* 设备以轮训接收模式打开 */
      +#define DEVICE_OFLAG_INT_TX     0x004 /* 设备以中断发送模式打开 */
      +#define DEVICE_OFLAG_INT_RX     0x008 /* 设备以中断接收模式打开 */
      +#define DEVICE_OFLAG_DMA_TX     0x010 /* 设备以 DMA 发送模式打开 */
      +#define DEVICE_OFLAG_DMA_RX     0x020 /* 设备以 DMA 接收模式打开 */
      +
      +
      +
      +
      +

      9.4.3. device_close

      +

      device_close 用于设备的关闭。

      +
      int device_close(struct device *dev);
      +
      +
      +
        +
      • dev 设备句柄

      • +
      • return 错误码,0 表示关闭成功,其他表示错误

      • +
      +
      +
      +

      9.4.4. device_control

      +

      device_control 用于根据命令对 ADC 设备进行控制和参数的修改。

      +
      int device_control(struct device *dev, int cmd, void *args);
      +
      +
      +
        +
      • dev 设备句柄

      • +
      • cmd 设备控制命令

      • +
      • args 控制参数

      • +
      • return 不同的控制命令返回的意义不同。

      • +
      +

      串口设备除了标准的控制命令,还具有自己特殊的控制命令。

      +
      #define DEVICE_CTRL_ADC_CHANNEL_START  0x10
      +#define DEVICE_CTRL_ADC_CHANNEL_STOP   0x11
      +#define DEVICE_CTRL_ADC_CHANNEL_CONFIG 0x12
      +#define DEVICE_CTRL_ADC_VBAT_ON        0x13
      +#define DEVICE_CTRL_ADC_VBAT_OFF       0x14
      +#define DEVICE_CTRL_ADC_TSEN_ON        0x15
      +#define DEVICE_CTRL_ADC_TSEN_OFF       0x16
      +
      +
      +

      args 根据不同的 cmd 传入不同,具体如下:

      + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

      cmd

      args

      description

      DEVICE_CTRL_SET_INT

      ADC_it_type

      开启ADC设备中断

      DEVICE_CTRL_CLR_INT

      ADC_it_type

      关闭ADC设备中断

      DEVICE_CTRL_CONFIG

      ADC_param_cfg_t*

      修改ADC配置

      DEVICE_CTRL_ADC_CHANNEL_CONFIG

      adc_channel_cfg_t*

      配置ADC通道信息

      DEVICE_CTRL_ATTACH_RX_DMA

      struct device*

      链接接收dma设备

      DEVICE_CTRL_ADC_CHANNEL_START

      struct device*

      开始/继续 ADC转换

      DEVICE_CTRL_ADC_CHANNEL_STOP

      NULL

      停止ADC转换

      DEVICE_CTRL_ADC_VBAT_ON

      NULL

      打开内部VDD测量电路

      DEVICE_CTRL_ADC_VBAT_OFF

      NULL

      关闭内部VDD测量电路

      DEVICE_CTRL_ADC_TSEN_ON

      NULL

      打开内部温度测量电路(需硬件支持)

      DEVICE_CTRL_ADC_TSEN_OFF

      uint32_t*

      关闭内部温度测量电路(需硬件支持)

      +
      +
      +

      9.4.5. device_read

      +

      device_read 用于 ADC 设备数据的接收,接收方式根据打开方式可以是轮询、中断、dma。

      +
      int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size);
      +
      +
      +
        +
      • dev 设备句柄

      • +
      • pos 无作用

      • +
      • buffer 要读入的 buffer 缓冲区

      • +
      • size 要读入的长度

      • +
      • return 错误码,0 表示读入成功,其他表示错误

      • +
      +
      +
      +

      9.4.6. device_set_callback

      +

      device_set_callback 用于注册一个ADC阈值中断回调函数。

      +
      int device_set_callback(struct device *dev, void (*callback)(struct device *dev, void *args, uint32_t size, uint32_t event));
      +
      +
      +
        +
      • dev 设备句柄

      • +
      • callback 要注册的中断回调函数

        +
        +
          +
        • dev 设备句柄

        • +
        • args 接收发送缓冲区,数据类型为 uint8_t*

        • +
        • size 传输长度

        • +
        • event 中断事件类型

        • +
        +
        +
      • +
      +

      串口设备 event 类型如下

      +
      enum ADC_event_type
      +{
      +    ADC_EVENT_FIFO_READY,
      +    ADC_EVENT_OVERRUN,
      +    ADC_EVENT_UNDERRUN,
      +};
      +
      +
      +
      diff --git a/docs/development_guide/build/html/api_reference/api_ble.html b/docs/development_guide/build/html/api_reference/api_ble.html index e71d92e2..b1f28e38 100644 --- a/docs/development_guide/build/html/api_reference/api_ble.html +++ b/docs/development_guide/build/html/api_reference/api_ble.html @@ -110,15 +110,14 @@

    基础外设例程

    进阶例程

      diff --git a/docs/development_guide/build/html/api_reference/api_clock.html b/docs/development_guide/build/html/api_reference/api_clock.html index 7ef5a483..2b058472 100644 --- a/docs/development_guide/build/html/api_reference/api_clock.html +++ b/docs/development_guide/build/html/api_reference/api_clock.html @@ -120,15 +120,14 @@

    基础外设例程

    进阶例程

      diff --git a/docs/development_guide/build/html/api_reference/api_dac.html b/docs/development_guide/build/html/api_reference/api_dac.html index 31de1072..510a2b1e 100644 --- a/docs/development_guide/build/html/api_reference/api_dac.html +++ b/docs/development_guide/build/html/api_reference/api_dac.html @@ -39,7 +39,7 @@ - + @@ -118,15 +118,14 @@

    基础外设例程

    进阶例程

      @@ -224,7 +223,7 @@
      diff --git a/docs/development_guide/build/html/api_reference/api_dma.html b/docs/development_guide/build/html/api_reference/api_dma.html index ff57d1ab..4cd34982 100644 --- a/docs/development_guide/build/html/api_reference/api_dma.html +++ b/docs/development_guide/build/html/api_reference/api_dma.html @@ -130,15 +130,14 @@

    基础外设例程

    进阶例程

      diff --git a/docs/development_guide/build/html/api_reference/api_gpio.html b/docs/development_guide/build/html/api_reference/api_gpio.html index 4ea237f3..07f62256 100644 --- a/docs/development_guide/build/html/api_reference/api_gpio.html +++ b/docs/development_guide/build/html/api_reference/api_gpio.html @@ -124,15 +124,14 @@

    基础外设例程

    进阶例程

      diff --git a/docs/development_guide/build/html/api_reference/api_i2c.html b/docs/development_guide/build/html/api_reference/api_i2c.html index 6a57796b..d2a74213 100644 --- a/docs/development_guide/build/html/api_reference/api_i2c.html +++ b/docs/development_guide/build/html/api_reference/api_i2c.html @@ -123,15 +123,14 @@

    基础外设例程

    进阶例程

      diff --git a/docs/development_guide/build/html/api_reference/api_pwm.html b/docs/development_guide/build/html/api_reference/api_pwm.html index 2b4bdfb2..d8e2b31b 100644 --- a/docs/development_guide/build/html/api_reference/api_pwm.html +++ b/docs/development_guide/build/html/api_reference/api_pwm.html @@ -129,15 +129,14 @@

    基础外设例程

    进阶例程

      @@ -219,30 +218,42 @@

      5.1. 简介

      脉冲宽度调制(Pulse width modulation,简称 PWM)是一种用数字方式实现模拟电压控制的技术。它是通过对一系列脉冲的宽度进行调制,等效出所需要的波形(包含形状以及幅值),对模拟信号电平进行数字编码,也就是说通过调节占空比的变化来调节信号、能量等的变化,占空比就是指在一个周期内,信号处于高电平的时间占据整个信号周期的百分比,例如方波的占空比就是50%。博流系列 MCU 中 DMA 设备具有以下特性:

        -
      • 支持5通道PWM信号生成

      • +
      • 支持5通道 PWM 信号生成

      • 三种时钟源可选择(总线时钟 <bclk>、晶振时钟 <xtal_ck>、慢速时钟 <32k>),搭配 16-bit 时钟分频器

      • 双门限值域设定,增加脉冲弹性

      5.2. PWM 设备结构体定义

      -
      typedef struct pwm_device
      -{
      +
      typedef struct pwm_device {
           struct device parent;
           uint8_t ch;
      -    uint32_t frequency;
      -    uint8_t dutycycle;
      +    uint8_t polarity_invert_mode;
      +    uint16_t period;
      +    uint16_t threshold_low;
      +    uint16_t threshold_high;
           uint16_t it_pulse_count;
      +
       } pwm_device_t;
       
      • parent 继承父类属性

      • ch 通道号,使能PWM通道0则ch为0,使能PWM通道0则ch为1,以此类推

      • -
      • frequency 默认频率

      • -
      • dutycycle 默认占空比(0-100)

      • +
      • polarity_invert_mode 极性翻转使能

      • +
      • period PWM 周期值

      • +
      • threshold_low PWM 低门限阈值

      • +
      • threshold_high PWM 高门限阈值

      • it_pulse_count 触发中断条件的周期计数值

      +
      +

      注解

      +

      PWM 实际频率 = PWM 时钟源/分频/period ,period 非 PWM 实际周期,

      +
      +
      +

      注解

      +

      PWM 占空比 = threshold_low/threshold_high * 100%

      +

      5.3. PWM 设备参数配置表

      @@ -250,15 +261,19 @@
      /*参数配置宏*/
       #if defined(BSP_USING_PWM_CH2)
       #ifndef PWM_CH2_CONFIG
      -#define PWM_CH2_CONFIG \
      -{   \
      -    .ch = 2, \
      -    .frequency = 1000000, \
      -    .dutycycle = 0, \
      -}
      +#define PWM_CH2_CONFIG                   \
      +    {                                    \
      +        .ch = 2,                         \
      +        .polarity_invert_mode = DISABLE, \
      +        .period = 0,                     \
      +        .threshold_low = 0,              \
      +        .threshold_high = 0,             \
      +        .it_pulse_count = 0,             \
      +    }
       #endif
       #endif
       
      +
       /*变量定义*/
       static pwm_device_t pwmx_device[PWM_MAX_INDEX] = {
       #ifdef BSP_USING_PWM_CH0
      @@ -372,9 +387,9 @@
       

      args 根据不同的 cmd 传入不同,具体如下:

      ---+++ @@ -385,27 +400,31 @@ - + - + - + - + - - - + + + - - - + + + + + + +

      cmd

      DEVICE_CTRL_SET_INT

      NULL

      开启pwm传输完成中断

      弃用

      DEVICE_CTRL_CLR_INT

      NULL

      关闭pwm传输完成中断

      弃用

      DEVICE_CTRL_RESUME

      NULL

      恢复pwm通道

      开启当前PWM通道

      DEVICE_CTRL_SUSPEND

      NULL

      挂起pwm通道

      关闭当前PWM通道

      DEVICE_CTRL_CONFIG

      pwm_config_t

      配置pwm通道频率和占空比

      DEIVCE_CTRL_PWM_FREQUENCE_CONFIG

      uint32_t

      配置当前PWM通道周期值

      DEIVCE_CTRL_PWM_IT_PULSE_COUNT_CONFIG

      uint32_t*

      配置中断计数阈值

      DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG

      pwm_dutycycle_config_t

      配置当前PWM通道占空比

      DEIVCE_CTRL_PWM_IT_PULSE_COUNT_CONFIG

      uint32_t

      配置触发PWM中断周期值

      diff --git a/docs/development_guide/build/html/api_reference/api_spi.html b/docs/development_guide/build/html/api_reference/api_spi.html index 651b3b14..0d1f15f2 100644 --- a/docs/development_guide/build/html/api_reference/api_spi.html +++ b/docs/development_guide/build/html/api_reference/api_spi.html @@ -130,15 +130,14 @@

    基础外设例程

    进阶例程

      diff --git a/docs/development_guide/build/html/api_reference/api_structure.html b/docs/development_guide/build/html/api_reference/api_structure.html index 3781a5f5..1f443b44 100644 --- a/docs/development_guide/build/html/api_reference/api_structure.html +++ b/docs/development_guide/build/html/api_reference/api_structure.html @@ -129,15 +129,14 @@

    基础外设例程

    进阶例程

      diff --git a/docs/development_guide/build/html/api_reference/api_uart.html b/docs/development_guide/build/html/api_reference/api_uart.html index 6b118e1b..b3cc369a 100644 --- a/docs/development_guide/build/html/api_reference/api_uart.html +++ b/docs/development_guide/build/html/api_reference/api_uart.html @@ -127,15 +127,14 @@

    基础外设例程

    进阶例程

      @@ -412,11 +411,11 @@

      DEVICE_CTRL_SET_INT

      uart_it_type

      -

      开启spi设备中断

      +

      开启uart设备中断

      DEVICE_CTRL_CLR_INT

      uart_it_type

      -

      关闭spi设备中断

      +

      关闭uart设备中断

      DEVICE_CTRL_CONFIG

      uart_param_cfg_t*

      diff --git a/docs/development_guide/build/html/genindex.html b/docs/development_guide/build/html/genindex.html index 7204c515..88fb7915 100644 --- a/docs/development_guide/build/html/genindex.html +++ b/docs/development_guide/build/html/genindex.html @@ -110,15 +110,14 @@

    基础外设例程

    进阶例程

      diff --git a/docs/development_guide/build/html/get_started/Linux_quick_start_ubuntu.html b/docs/development_guide/build/html/get_started/Linux_quick_start_ubuntu.html index 75707cb7..8e6e2ac0 100644 --- a/docs/development_guide/build/html/get_started/Linux_quick_start_ubuntu.html +++ b/docs/development_guide/build/html/get_started/Linux_quick_start_ubuntu.html @@ -132,15 +132,14 @@

    基础外设例程

    进阶例程

      @@ -242,7 +241,7 @@ $ wget -c https://dev.bouffalolab.com/media/upload/download/riscv64-elf-x86_64-20210120.tar.gz $ mkdir -p riscv64-elf-20210120 $ tar -zxvf riscv64-elf-x86_64-20210120.tar.gz -C riscv64-elf-20210120 -$ sudo cp ~/riscv64-elf-20210120 /usr/bin +$ sudo cp -rf ~/riscv64-elf-20210120 /usr/bin $ echo "export PATH=\"$PATH:/usr/bin/riscv64-elf-20210120/bin\"" >> ~/.bashrc $ source ~/.bashrc @@ -262,7 +261,7 @@ $ sudo apt install make $ cd ~ $ wget -c https://cmake.org/files/v3.19/cmake-3.19.3-Linux-x86_64.tar.gz $ tar -zxvf cmake-3.19.3-Linux-x86_64.tar.gz -$ sudo cp ~/cmake-3.19.3-Linux-x86_64 /usr/bin +$ sudo cp -rf ~/cmake-3.19.3-Linux-x86_64 /usr/bin $ echo "export PATH=\"$PATH:/usr/bin/cmake-3.19.3-Linux-x86_64/bin\"" >> ~/.bashrc $ source ~/.bashrc @@ -351,7 +350,7 @@ $ wget -c https://cmake.org/files/v3.19/cmake-3.19.3-Linux-x86_64.tar.gz
    1
     2
     $ sudo apt install picocom   # 若已经安装请忽略
    - $ picocom -b 2000000 /dev/ttyUSB0
    + $ picocom -b 2000000 /dev/ttyUSB0 # 注意你的可用串口号 (如使用 Sipeed RV-debugger)
     
    @@ -131,15 +136,14 @@

    基础外设例程

    进阶例程

    基础外设例程

    进阶例程

      diff --git a/docs/development_guide/build/html/searchindex.js b/docs/development_guide/build/html/searchindex.js index 7d5528b7..75de9eed 100644 --- a/docs/development_guide/build/html/searchindex.js +++ b/docs/development_guide/build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["api_reference/api_adc","api_reference/api_clock","api_reference/api_dac","api_reference/api_dma","api_reference/api_gpio","api_reference/api_i2c","api_reference/api_pwm","api_reference/api_spi","api_reference/api_structure","api_reference/api_uart","get_started/Linux_quick_start_ubuntu","get_started/Windows_quick_start_cdk","get_started/Windows_quick_start_eclipse","get_started/bl_dev_cube","get_started/cmake_quick_start","get_started/connecting_hardware","get_started/get_started","get_started/index","index","samples/advance samples/ble_scan_demo","samples/advance samples/boot2_iap_info","samples/advance samples/fatfs_demo","samples/advance samples/lowpower_demo","samples/advance samples/shell_demo","samples/basic samples/adc_key_demo","samples/basic samples/blink_demo","samples/basic samples/breath_pwm_demo","samples/basic samples/button_demo","samples/basic samples/dma_m2m_demo","samples/basic samples/i2c_eeprom_demo","samples/basic samples/mtimer_demo","samples/basic samples/spi_lcd_demo","samples/basic samples/uart_loopback_demo"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":2,sphinx:56},filenames:["api_reference\\api_adc.rst","api_reference\\api_clock.rst","api_reference\\api_dac.rst","api_reference\\api_dma.rst","api_reference\\api_gpio.rst","api_reference\\api_i2c.rst","api_reference\\api_pwm.rst","api_reference\\api_spi.rst","api_reference\\api_structure.rst","api_reference\\api_uart.rst","get_started\\Linux_quick_start_ubuntu.rst","get_started\\Windows_quick_start_cdk.rst","get_started\\Windows_quick_start_eclipse.rst","get_started\\bl_dev_cube.rst","get_started\\cmake_quick_start.rst","get_started\\connecting_hardware.rst","get_started\\get_started.rst","get_started\\index.rst","index.rst","samples\\advance samples\\ble_scan_demo.rst","samples\\advance samples\\boot2_iap_info.rst","samples\\advance samples\\fatfs_demo.rst","samples\\advance samples\\lowpower_demo.rst","samples\\advance samples\\shell_demo.rst","samples\\basic samples\\adc_key_demo.rst","samples\\basic samples\\blink_demo.rst","samples\\basic samples\\breath_pwm_demo.rst","samples\\basic samples\\button_demo.rst","samples\\basic samples\\dma_m2m_demo.rst","samples\\basic samples\\i2c_eeprom_demo.rst","samples\\basic samples\\mtimer_demo.rst","samples\\basic samples\\spi_lcd_demo.rst","samples\\basic samples\\uart_loopback_demo.rst"],objects:{},objnames:{},objtypes:{},terms:{"0v":24,"0x":29,"0x00":29,"0x0000":5,"0x00000000":3,"0x00000001":3,"0x00000002":3,"0x00000003":3,"0x00000006":3,"0x00000007":3,"0x0000000a":3,"0x0000000b":3,"0x00000014":3,"0x00000015":3,"0x00000016":3,"0x00000017":3,"0x00000018":3,"0x00000019":3,"0x0000001a":3,"0x0000001b":3,"0x0000001c":3,"0x0000001d":3,"0x0000001e":3,"0x0000001f":3,"0x0001":5,"0x001":[3,5,6,7,8,9],"0x0010":5,"0x0018":[],"0x002":[3,5,6,7,8,9],"0x0020":5,"0x0028":[],"0x004":[3,5,6,7,8,9],"0x0040":5,"0x008":[3,5,6,7,8,9],"0x00a0":[],"0x00f0":[],"0x01":[8,19],"0x010":[3,5,6,7,8,9],"0x0180":19,"0x02":[8,19],"0x020":[3,5,6,7,8,9],"0x03":[8,19],"0x04":[8,19],"0x05":[8,19],"0x06":[8,19],"0x07":[8,19],"0x08":[8,19],"0x09":[8,19],"0x0a":8,"0x0b":8,"0x0c":8,"0x0d":8,"0x0e":8,"0x0f":8,"0x10":[3,6,7,9],"0x1000":8,"0x11":[3,9],"0x12":[3,19],"0x13":[3,19],"0x18":19,"0x1812":19,"0x2000":8,"0x3000":8,"0x50":29,"0x71":19,"0x80":19,"0xff":28,"10":[4,10,19,22],"100":6,"1000":24,"1000000":[6,26,30],"11":[4,19],"12":[4,19],"13":[4,19],"14":[19,22],"15":[5,19,29],"16":[3,6,19],"17":19,"18":[16,19],"18000000":7,"19":[10,19],"1m":30,"1s":[22,30],"1v":24,"20":19,"2000000":[9,10,32],"20210120":10,"244":19,"28":22,"2f":24,"2m":13,"2v":24,"31":22,"32":[3,28],"32768":22,"32k":[6,22],"32m":22,"36000000":31,"3v":24,"3v3":15,"400":[],"40m":7,"43v":24,"4ghz":[],"4k":22,"50":6,"625":[],"64":30,"64k":22,"68":22,"8000":28,"break":9,"case":[12,14],"char":[3,5,6,7,8,9,19],"const":[3,5,6,7,8,9,19],"do":15,"enum":[1,3,5,6,7,8,9],"export":10,"for":[10,28],"function":[24,25,26,27,29,31,32],"if":[3,5,6,7,9,19,24,26,28,29,31,32],"import":12,"in":[19,20],"int":[3,4,5,6,7,8,9,19],"null":[3,6,7,8,9,19,28],"public":[],"return":[3,4,5,6,7,8,9,19],"static":[3,5,6,7,9,19,27,30],"try":[],"void":[3,4,6,7,8,9,19,24,27,28,30,31,32],"while":[19,22],"with":[],access:3,acknowledg:[],acl:[],activ:[],ad:[],ad_discov:[],ad_len:[],adc0:[3,24],adc0_config:24,adc0_index:24,adc:[8,18],adc_channel_cfg:24,adc_channel_cfg_t:24,adc_channel_start:24,adc_clock_div_32:24,adc_data_width_16b_with_256_averag:24,adc_dev:24,adc_fifo_threshold_1byt:24,adc_gain_1:24,adc_kei:24,adc_regist:24,adc_vref_3p2v:24,add:11,addr:[],addr_typ:[],address:[],adv:19,adv_addr:[],adv_data:19,adv_nam:19,adv_param:19,advanc:13,advertis:[],after:[],all:13,an:[],and:[],ani:[],aon:22,api:18,app:[10,12,14,19,22,24,25,26,27,28,29,30,31,32],appear:[],appli:12,applic:[12,20],apt:10,are:[],arg:[3,6,7,8,9,28,32],array_s:19,as:19,asynchron:9,at24cxx:18,atomic_defin:[],atomic_t:[],attr:19,attribut:[],bashrc:10,baudrat:[9,32],bclk:6,be:19,bearer:[],befor:[],bflb_mcu_prefer:12,bflb_platform_init:32,bflb_platform_set_alarm_tim:30,bin:[10,11,12,13,20],bit:[6,9],bl602:[],bl702:[10,11,12,16,18,19],bl702_avb:31,bl702_bl704_bl706_ds_en_combo_1:22,bl702_driver:31,bl702_iot:15,bl706:[12,15,20,22],bl706_avb:[16,24,31],bl706_iot:[10,12,14,16,19,24,25,26,27,28,29,30,32],bl706_lp:22,bl70x:[15,18,22],bl70x_flash:11,bl70x_flasher:11,bl:[4,22],bl_clean:12,bl_make:12,bl_mcu_sdk:[8,14,19,20,22,24,25,26,27,28,29,30,31,32],bl_test_01:19,bldevcub:[18,19,24,25,26,27,28,29,30,31,32],ble:18,ble_centr:19,ble_controller_init:[],ble_peripher:19,ble_start_adv:19,ble_start_scan:19,ble_tp_conn:19,ble_tp_conn_callback:19,ble_tp_connect:19,ble_tp_disconnect:19,ble_tp_init:19,ble_tp_notify_task:19,ble_tp_recv_wr:19,ble_write_data:19,ble_write_data_task:19,bluetooth:[],board:[1,3,4,5,6,7,9,10,12,14,15,19,22,24,25,26,27,28,29,30,31,32],board_get_debug_uart_index:32,bool:[],boot2:18,boot2_iap:20,boot:[10,13,15],boot_rom:10,borad:12,bouffalo:[12,15,16,20],bouffalolab:[10,11,12,13],boufflao:22,br:[],breath:26,broadcast:[],brows:13,bsp:[1,3,4,5,6,7,9,24,26,28,29,31,32],bsp_adc_clock_div:24,bsp_adc_clock_sourc:24,bsp_i2c_clock_div:29,bsp_i2c_clock_sourc:29,bsp_spi_clock_div:31,bsp_spi_clock_sourc:31,bsp_uart_clock_div:32,bsp_uart_clock_sourc:32,bsp_using_adc0:24,bsp_using_dma0_ch0:[3,28],bsp_using_dma0_ch1:3,bsp_using_dma0_ch2:3,bsp_using_dma0_ch3:3,bsp_using_dma0_ch4:3,bsp_using_dma0_ch5:3,bsp_using_dma0_ch6:3,bsp_using_dma0_ch7:3,bsp_using_dma_ch0:3,bsp_using_i2c0:[5,29],bsp_using_pwm_ch0:6,bsp_using_pwm_ch1:6,bsp_using_pwm_ch2:[6,26],bsp_using_pwm_ch3:6,bsp_using_pwm_ch4:6,bsp_using_spi0:[7,31],bsp_using_uart0:[9,32],bsp_using_uart1:9,bt:[],bt_addr_le_ani:[],bt_addr_le_t:[],bt_char_ble_tp_not_attr_val_index:19,bt_conn:19,bt_conn_auth_cancel:[],bt_conn_auth_cb:[],bt_conn_auth_cb_regist:[],bt_conn_auth_passkey_confirm:[],bt_conn_auth_passkey_entri:[],bt_conn_auth_pincode_entri:[],bt_conn_br:[],bt_conn_cb:19,bt_conn_cb_regist:19,bt_conn_create_auto_l:[],bt_conn_create_auto_stop:[],bt_conn_create_l:[],bt_conn_create_slave_l:[],bt_conn_disconnect:[],bt_conn_enc_key_s:[],bt_conn_get_info:[],bt_conn_get_remote_dev_info:[],bt_conn_get_secur:[],bt_conn_info:[],bt_conn_l:[],bt_conn_le_param_upd:[],bt_conn_num_flag:[],bt_conn_rv:[],bt_conn_sco:[],bt_conn_set_secur:[],bt_conn_state_t:[],bt_data:19,bt_data_byt:[],bt_data_flag:19,bt_data_gap_appear:19,bt_data_manufacturer_data:19,bt_data_name_complet:19,bt_data_uuid16_al:19,bt_enabl:[],bt_gap_adv_fast_int_max_3:19,bt_gap_adv_fast_int_min_3:19,bt_gap_init_conn_int_max:[],bt_gap_init_conn_int_min:[],bt_gap_scan_slow_interval_1:[],bt_gap_scan_slow_window_1:[],bt_gatt_attr:19,bt_gatt_notifi:19,bt_gatt_subscribe_param:19,bt_gatt_write_without_respons:19,bt_get_local_address:[],bt_le_ad_gener:[],bt_le_ad_limit:19,bt_le_ad_no_bredr:19,bt_le_adv_opt_connect:[],bt_le_adv_opt_dir_addr_rpa:[],bt_le_adv_opt_dir_mode_low_duti:[],bt_le_adv_opt_filter_conn:[],bt_le_adv_opt_filter_scan_req:[],bt_le_adv_opt_non:[],bt_le_adv_opt_one_tim:[],bt_le_adv_opt_use_ident:[],bt_le_adv_opt_use_nam:[],bt_le_adv_param:19,bt_le_adv_start:19,bt_le_adv_stop:[],bt_le_adv_update_data:[],bt_le_conn_param:[],bt_le_read_rssi:[],bt_le_scan_cb_t:[],bt_le_scan_param:[],bt_le_scan_start:[],bt_le_scan_stop:[],bt_le_scan_type_act:[],bt_le_scan_type_pass:[],bt_le_set_auto_conn:[],bt_le_set_chan_map:[],bt_le_whitelist_add:[],bt_le_whitelist_clear:[],bt_le_whitelist_rem:[],bt_ready_cb_t:[],bt_security_t:[],bt_set_bond:[],bt_set_tx_pwr:[],bt_unpair:[],bt_warn:19,buf:[5,19,29],buffer:[7,8,9],build:[10,11,12],bus:7,but:[],by:[],call:[],callback:[3,6,7,8,9,19],can:[],cancel:12,canon:10,care:[],cb:[],cbfun:4,cd:[10,19,24,25,26,27,28,29,30,31,32],cdk:[16,19,22,24,25,26,27,28,29,30,31,32],cdk_flashload:11,cdkproj:[11,24,25,26,27,28,29,30,31,32],central:[],cfg:6,ch8:24,ch:[3,5,6,26,28],chan_map:[],channel:[],char_hdl:19,characterist:[],check:[],chip:13,circuit:5,ck:[11,16],ck_link:15,clean:11,clear:8,click:13,client:[],clk:[7,31],clk_div:24,clk_phase:[7,31],clk_polara:[7,31],clock:[13,22],clock_config:[24,29,31,32],clock_period:22,clone:[10,11,12],close:8,cmake:18,cmake_current_source_dir:14,cmakelist:14,cmd:[3,6,7,8,9],code:8,com:[10,11,12,13,15],command:12,complet:19,compromis:[],config:8,config_bt_bredr:[],config_bt_privaci:[],config_bt_remote_vers:[],config_bt_smp:[],config_bt_stack_pt:[],config_gpio11_func:29,config_gpio14_func:32,config_gpio15_func:32,config_gpio16_func:29,config_gpio18_func:24,config_gpio19_func:31,config_gpio20_func:31,config_gpio21_func:31,config_gpio22_func:26,configur:8,conn:19,connect:[15,19],consol:12,continuous_conv_mod:24,control:8,conveni:[],core:18,count:6,cp:10,cpha:7,cpol:7,cpu:[11,22],creat:13,cs1:31,cs1_high:31,cs1_low:31,cs:7,csky:11,ctrl:8,cts:9,cube:[15,20],d0:25,d1:25,d2:25,d3:25,dac0:3,dac:18,data:[9,19,31],data_appear:19,data_len:[],data_manu:19,data_uuid:19,data_width:24,databit:[9,32],datas:[7,31],datasheet:22,dc:31,dc_high:31,debug:[11,12],debug_log:32,debugg:[11,13,16],default_config:31,defer:[],defin:[3,4,5,6,7,8,9,24,26,28,29,31,32],deivce_ctrl_pwm_it_pulse_count_config:6,delai:[],demo:[12,19,23,24,25,26,27,28,29,30,31,32],descript:[3,6,7,9],determin:[],dev:[3,5,6,7,8,9,10,12,15,20,28,32],devcub:20,devic:[3,5,6,7,8,9,13,24,26,28,29,32],device_class_adc:8,device_class_camera:8,device_class_dma:8,device_class_gpio:8,device_class_i2:8,device_class_i2c:8,device_class_non:8,device_class_pwm:8,device_class_sdio:8,device_class_sec_hash:8,device_class_spi:8,device_class_tim:8,device_class_typ:8,device_class_uart:8,device_class_usb:8,device_clos:31,device_contorl:26,device_control:[24,26,28,32],device_ctrl_adc_channel_config:24,device_ctrl_attach_rx_dma:[7,8,9],device_ctrl_attach_tx_dma:[7,8,9],device_ctrl_clr_int:[3,6,7,8,9],device_ctrl_config:[6,8,9,26],device_ctrl_get_config:8,device_ctrl_get_int:8,device_ctrl_resum:[6,7,8],device_ctrl_resvd1:8,device_ctrl_resvd2:8,device_ctrl_rx_dma_resum:[7,8,9],device_ctrl_rx_dma_suspend:[7,8,9],device_ctrl_set_int:[3,6,7,8,9,28,32],device_ctrl_spi_config_clock:7,device_ctrl_suspend:[6,7,8],device_ctrl_tx_dma_resum:[7,8,9],device_ctrl_tx_dma_suspend:[7,8,9],device_ctrl_uart_get_rx_fifo:9,device_ctrl_uart_get_tx_fifo:9,device_find:[24,26,28,29,31,32],device_found:19,device_oflag_dma_rx:[3,5,6,7,8,9],device_oflag_dma_tx:[3,5,6,7,8,9],device_oflag_int_rx:[3,5,6,7,8,9,32],device_oflag_int_tx:[3,5,6,7,8,9],device_oflag_rdonli:8,device_oflag_rdwr:[8,26,28,29,31,32],device_oflag_stream_rx:[3,5,6,7,8,9,24,31],device_oflag_stream_tx:[3,5,6,7,8,9,26,31,32],device_oflag_wronli:8,device_open:[24,26,28,29,31,32],device_read:24,device_set_callback:[28,32],device_status_typ:8,device_writ:32,differential_mod:24,direct:[3,7,28,31],disabl:24,disconnect:19,displai:31,dl:13,dlist_t:8,dma0_ch0_config:[3,28],dma0_ch0_index:[3,28],dma0_ch1_config:3,dma0_ch1_index:3,dma0_ch2_config:3,dma0_ch2_index:3,dma0_ch3_config:3,dma0_ch3_index:3,dma0_ch4_config:3,dma0_ch4_index:3,dma0_ch5_config:3,dma0_ch5_index:3,dma0_ch6_config:3,dma0_ch6_index:3,dma0_ch7_config:3,dma0_ch7_index:3,dma:[5,6,7,8,9,18],dma_burst_16byt:3,dma_burst_1byt:3,dma_burst_4byt:3,dma_burst_8byt:3,dma_ch0:28,dma_ch0_index:3,dma_channel_get_statu:3,dma_channel_start:28,dma_dev:3,dma_devic:3,dma_device_t:3,dma_dst_buff:28,dma_event_complet:3,dma_event_typ:3,dma_index_typ:3,dma_lli_ctrl_t:3,dma_lli_cycle_mod:3,dma_lli_once_mod:[3,28],dma_m2m:28,dma_max_index:3,dma_memory_to_memori:[3,28],dma_memory_to_periph:3,dma_periph_to_memori:3,dma_periph_to_periph:3,dma_regist:28,dma_reload:28,dma_request_adc0:3,dma_request_dac0:3,dma_request_i2c0_rx:3,dma_request_i2c0_tx:3,dma_request_i2s_rx:3,dma_request_i2s_tx:3,dma_request_non:[3,28],dma_request_spi0_rx:3,dma_request_spi0_tx:3,dma_request_uart0_rx:3,dma_request_uart0_tx:3,dma_request_uart1_rx:3,dma_request_uart1_tx:3,dma_request_usb_ep0:3,dma_request_usb_ep1:3,dma_request_usb_ep2:3,dma_request_usb_ep3:3,dma_request_usb_ep4:3,dma_request_usb_ep5:3,dma_request_usb_ep6:3,dma_request_usb_ep7:3,dma_src_buff:28,dma_transfer_dir_typ:3,dma_transfer_don:28,dma_transfer_width_16bit:3,dma_transfer_width_32bit:[3,28],dma_transfer_width_8bit:3,dmax_devic:3,don:[],done:28,download:[10,11,12,13],driver:[13,31],dst_addr:3,dst_burst_siz:3,dst_req:[3,28],dst_width:[3,28],dtcm:22,duti:[],dutycycl:[6,26],e24:18,echo:10,eclips:16,edit:12,eeprom:29,effect:[],elf:[10,11,12],els:[24,31,32],enabl:[4,24,27],encrypt:[],endif:[3,5,6,7,9,24,26,28,29,31,32],ep0:3,ep1:3,ep2:3,ep3:3,ep4:3,ep5:3,ep6:3,ep7:3,epf:12,err:19,error:[19,28],even:9,event:[3,6,7,8,9],exampl:[10,11,12,19,20,22,24,25,26,27,28,29,30,31,32],exe:[11,12,13],exist:12,fail:24,fatf:18,featur:[],field:[],fifo:[7,9,32],fifo_threshold:[7,9,24,31,32],file:[10,12,13],filter:[],filter_dup:[],find:[24,26,28,29,31,32],finish:[12,13],finsh:12,flag:[3,5,6,7,8,9,19,29],flash:[11,13,20],flashdownload:11,freerto:14,frequenc:[6,26],friend:[],gain:24,gap:[],gate:22,gatt:[],gdb:12,gener:[4,12],generate_bin:14,get:8,get_adc_key_valu:24,get_attr:19,git:[10,11,12],gite:[10,11,12],gnd:[12,15],gpio10:31,gpio11:[27,29],gpio11_int_callback:27,gpio14:32,gpio15:32,gpio16:29,gpio18:24,gpio19:31,gpio20:31,gpio21:31,gpio22:[25,26,31],gpio29:25,gpio30:25,gpio31:25,gpio:[12,18,22,24,26,29,31,32],gpio_async_falling_triger_int_mod:4,gpio_async_high_level_int_mod:4,gpio_async_low_level_int_mod:4,gpio_async_rising_triger_int_mod:4,gpio_attach_irq:27,gpio_blink:[12,25],gpio_cas:14,gpio_fun_adc:24,gpio_fun_i2c:29,gpio_fun_pwm:26,gpio_fun_spi:31,gpio_fun_uart0_rx:32,gpio_fun_uart0_tx:32,gpio_input_mod:4,gpio_input_pd_mod:4,gpio_input_pp_mod:4,gpio_int:27,gpio_irq_en:27,gpio_output_mod:[4,31],gpio_output_pd_mod:4,gpio_output_pp_mod:[4,25],gpio_pin_11:27,gpio_pin_22:25,gpio_pin_29:25,gpio_pin_30:25,gpio_pin_31:25,gpio_set_mod:[25,27,31],gpio_sync_falling_triger_int_mod:4,gpio_sync_high_level_int_mod:4,gpio_sync_low_level_int_mod:4,gpio_sync_rising_triger_int_mod:[4,27],gpio_test_cas:14,gpio_writ:[25,31],guest:13,gz:10,hal:8,hal_dma:3,hal_drv:31,hal_i2c:5,hal_pwm:6,hal_spi:7,hal_uart:9,handl:8,happen:[],hardwar:[],hbn:22,hci:[],hci_driver_init:[],hd1:15,hd3:15,hellowd:[10,11,12],helloworld:[10,11,12],help:11,here:13,high:[],host:[],http:[10,11,12,13],i2c0:[5,29],i2c0_config:[5,29],i2c0_index:[5,29],i2c1:5,i2c:[3,18],i2c_at24cxx:29,i2c_dev:5,i2c_devic:5,i2c_device_t:5,i2c_hw_mod:[5,29],i2c_index_typ:5,i2c_max_index:5,i2c_msg:5,i2c_msg_t:[5,29],i2c_rd:[5,29],i2c_regist:29,i2c_scl:29,i2c_sda:29,i2c_transf:29,i2c_wr:[5,29],i2cx_devic:5,i2s:3,iap:18,id:[3,5,7,9,28,29,31,32],ident:[],identifi:[],ifdef:[3,5,6,7,9],ifndef:[3,5,6,7,9,24,26,28,29,31,32],imag:13,incom:[],index:[3,5,6,7,9,28],indic:[],info:[],input:4,instal:10,int8_t:[],inter:5,interfac:[7,10,13],intergr:5,interrupt:8,interv:[],interval_max:19,interval_min:19,into:12,iot:[12,15,18],is:9,isregist:19,it:[],it_pulse_count:[6,26],itcm:22,its:[],jlink:[15,16],jlink_bl_mcu_sdk:12,jtag:[13,15,16,18],jtag_tck:15,jtag_tdi:15,jtag_tdo:15,jtag_tm:15,k_delayed_work:[],k_fifo:[],k_forev:19,k_sem_giv:19,k_sem_tak:19,k_work:[],keep:[],kei:24,keil:[24,25,26,27,28,29,30,31,32],key_no_valu:24,keyvalu:24,l2cap:[],lab:[12,15,16,20,22],latenc:[],launch:12,lcd:18,lcd_c:31,lcd_cs_pin:31,lcd_dc:31,lcd_dc_pin:31,lcd_wr_byte:31,lcd_wr_halfword:31,lcd_wr_word:31,le:[],led:26,led_breath:26,len:[5,19,29],length:[7,9,19],level:22,lin:9,link:[11,12,16],linker_script:14,linux:[16,17,22,23],list:[3,8,13],ll:[],lli:3,lli_cfg:3,loader:11,local:[],log:12,low:[],lowpow:18,lowpower_test:22,lpn:[],lsb:7,lts:16,ma:22,main:[10,12,14],maix:13,make:[12,14,19,22,24,25,26,27,28,29,30,31,32],manag:[],manufactur:[],map:[],maximum:[],mcu:[3,4,5,6,7,9,10,11,12,13,15,16,22],mdk:[24,25,26,27,28,29,30,31,32],meaning:[],media:10,memori:[3,28],mesh:[],mini:[10,13,15],minimum:[],miso:31,mkdir:10,mobaxterm:23,mode:[4,5,7,29,31],modul:6,mosi:31,ms:[],msb:7,msg:[5,24,27,28,29,30,32],mtimer:18,must:19,mv:24,my_cas:14,name:[3,5,6,7,8,9,19],name_max:8,need:[],neg_channel:24,negchlist:24,net_buf:[],next:12,no:9,node:8,none:3,not:[],notif:19,notifi:19,notify_func:19,notify_poll_sem:19,num:5,observ:[],occ:11,occur:[],ocram:22,octam:22,odd:9,of:8,ofast:14,offset:19,oflag:[3,5,6,7,8,9],ok:11,one:[9,19],onli:[],oob:[],open:[8,24],option:[13,19],or:[13,15,16,19,23],org:10,os:30,ostrac:11,other:[],otherwis:[],out:12,outgo:[],output:4,over:12,own:[],own_address_typ:[],packet:[],page:22,pair:[],pane:11,param:19,paramet:[],parent:[3,5,6,7,8,9],pariti:[9,32],passkei:[],path:10,pb:[],pc:[12,15,16,22,23],pdf:22,pds:22,peer:[],pending_no_cb:[],peripher:[3,7,11],peripheral_clock_adc:1,peripheral_clock_dac:1,peripheral_clock_i2:1,peripheral_clock_i2c:1,peripheral_clock_spi:1,peripheral_clock_typ:1,peripheral_clock_uart:1,peripheral_config:[3,5,6,7,9,24,26,28,29,31,32],phase:[5,29],picocom:10,pin:[4,24,25,26,27,29,31,32],pinmux:4,pinmux_config:[4,24,26,31,32],pinmux_lvgl:31,pinmux_select:31,port:13,pos:[7,8,9],pos_channel:24,poschlist:24,power:22,prefer:12,press:24,privaci:[],privat:[],profil:11,program:[13,20],project:[11,12],provid:[],provis:[],proxi:[],psram:13,puls:6,purpos:4,pvparamet:19,pwm:[3,18],pwm_breath_l:26,pwm_cfg:26,pwm_ch0_config:6,pwm_ch0_index:6,pwm_ch1_config:6,pwm_ch1_index:6,pwm_ch2:26,pwm_ch2_config:[6,26],pwm_ch2_index:[6,26],pwm_ch3_config:6,pwm_ch3_index:6,pwm_ch4_config:6,pwm_ch4_index:6,pwm_channel_start:26,pwm_config_t:[6,26],pwm_dev:6,pwm_devic:6,pwm_device_t:6,pwm_event_complet:6,pwm_event_typ:6,pwm_index_typ:6,pwm_max_index:6,pwm_regist:26,pwmx_devic:6,queue:[],radio:[],ram:[18,22],random:[],rang:[],read:[8,29],reason:[],receiv:9,recurs:[10,11,12],recv_buf:7,ref:[],refresh:[13,15],regist:11,relai:[],remot:[],replac:13,request:3,requir:[],required_sec_level:[],resolut:[],resolv:[],resourc:[],respons:[],result_v:24,resum:8,risc:[12,18,30],riscv64:10,rise:27,role:[],rom:[13,15],root_clock_source_bclk:[29,31],root_clock_source_pll_96m:32,root_clock_source_xclk:24,rpa:[],rssi:[],rst:[10,11,12,13,15],rtc:22,rto:[9,32],rts:9,run:22,rv:13,rx0:15,rx:[3,7,9,22,32],rx_dma:[7,9],rx_len:[],rxd0:12,rxd:15,same:19,scan:[],scan_param:[],scan_rsp:[],sclk:7,sco:[],sd:[],sd_len:[],sdi:7,sdk:[4,10,11,12,14],sdk_path:[19,24,25,26,27,28,29,30,31,32],sdo:7,sec:[],sec_level:[],secur:[],segger:[12,13],select:13,send:19,send_buf:7,sent:[],serial:[7,11],server:[],servic:19,set:[8,11,14],setup:11,shell:18,show:13,sifiv:18,simpl:[],sipe:[13,16],size:[3,6,7,8,9,28,32],size_t:[],sizeof:19,sky:11,slave:[],slaveaddr:[5,29],sleeptim:22,smp:[],so:[],solicit:[],sourc:10,spec:22,specif:[],specifi:[],speed:13,spi0:[7,31],spi0_config:[7,31],spi0_index:[7,31],spi:[3,8,9,18],spi_config:31,spi_datasize_16bit:7,spi_datasize_24bit:7,spi_datasize_32bit:7,spi_datasize_8bit:[7,31],spi_dev:7,spi_devic:7,spi_device_t:7,spi_event_rx_fifo:7,spi_event_tx_fifo:7,spi_event_typ:7,spi_event_unknown:7,spi_index_typ:7,spi_lcd:31,spi_lsb_byte0_direction_first:7,spi_lsb_byte3_direction_first:7,spi_master_mod:[7,31],spi_max_index:7,spi_miso:31,spi_mosi:31,spi_msb_byte0_direction_first:[7,31],spi_msb_byte3_direction_first:7,spi_phase_1edg:[7,31],spi_phase_2edg:7,spi_polarity_high:7,spi_polarity_low:[7,31],spi_regist:31,spi_sck:31,spi_slvae_mod:7,spi_swap_en:31,spi_transfer_tpye_24bit:7,spi_transfer_type_16bit:[7,31],spi_transfer_type_32bit:[7,31],spi_transfer_type_8bit:[7,31],spi_transmit:31,spix_devic:7,src_addr:3,src_burst_siz:3,src_req:[3,28],src_width:[3,28],stack:[],start:11,state:[28,32],statu:8,std:8,step:12,stop:[9,11],stopbit:[9,32],strlen:19,struct:[3,5,6,7,8,9,19,26,28,29,32],structur:8,sub_addr_0byt:5,sub_addr_1byt:[5,29],sub_addr_2byt:5,subaddr:[5,29],subsystem:10,subvers:[],success:[11,13,28,29],sudo:10,support:[],support_bl:19,support_float:19,support_freerto:[14,19],support_shel:22,suspend:8,sw1:[24,27],sw5:24,sync:9,sys_slist_t:[],system:11,system_clock_bclk:1,system_clock_fclk:1,system_clock_root_clock:1,system_clock_typ:1,system_clock_xclk:1,systick:30,systick_isr:30,tabl:4,take:[],taken:[],tar:10,target:12,target_required_lib:14,target_required_private_opt:14,target_required_src:14,task:28,task_prior:[],tck:15,tdi:15,tdo:15,test1:14,test2:14,tft:18,that:[],the:19,thi:19,tick:30,time:19,timeout:[],tk:[],tms:15,to:[3,13,15,19,28],togeth:[],tool:[11,13],tp:19,tp_wr_hdl:19,transfer:[3,28],transfer_mod:[3,28],transfer_s:3,transmitt:9,trigger:27,ttl:[10,11,12,15,16,20,22],ttyusb0:10,two:9,tx0:15,tx:[3,7,9],tx_complet:[],tx_complete_work:[],tx_dma:[7,9],tx_mtu_siz:19,tx_pend:[],tx_queue:[],txd0:12,txd:15,txt:14,tyep:3,type:[1,7,8,11,12,13,15],typedef:[3,5,6,7,8,9],u16_t:19,u32_t:[],u8_t:19,ua:22,uart0:[3,9,15,32],uart0_config:[9,32],uart0_index:9,uart0_rx:32,uart0_tx:32,uart1:3,uart1_config:9,uart1_index:9,uart:[10,18,22],uart_data_len_5:9,uart_data_len_6:9,uart_data_len_7:9,uart_data_len_8:[9,32],uart_databits_t:9,uart_dev:9,uart_devic:9,uart_device_t:9,uart_echo:32,uart_event_rto:[9,32],uart_event_rx_end:9,uart_event_rx_fifo:[9,32],uart_event_tx_end:9,uart_event_tx_fifo:9,uart_event_typ:9,uart_event_unknown:9,uart_index_typ:9,uart_iqr_callback:32,uart_irq_callback:32,uart_it_typ:9,uart_max_index:9,uart_par_even:9,uart_par_non:[9,32],uart_par_odd:9,uart_param_cfg_t:9,uart_parity_t:9,uart_regist:32,uart_rto_it:32,uart_rx_fifo_it:32,uart_stop_on:[9,32],uart_stop_one_d_f:9,uart_stop_two:9,uart_stopbits_t:9,uartx_devic:9,ubuntu:[10,16],uint16_t:[3,5,6,7,8,9,31],uint32_t:[1,3,4,5,6,7,8,9,27,28,30,31,32],uint8_t:[3,4,5,6,7,9,19,29,31,32],undirect:19,uniform:[],union:[],univers:9,unknow:19,unsign:[],updat:10,update_work:[],upload:10,usart:20,usb:[3,10,11,12,13,15,16,20,22,23],use:[],used:[],user:20,uses:[],using:[],usr:10,uuid:[],v10:13,v11:[13,16],v3:10,valu:4,vdd33:15,vdd:15,version:[],vi:10,view:[11,13],viewer:11,volt:24,vref:[15,24],vtref:15,warn:[],we:[],welcom:12,wfi:22,wget:10,when:[],which:[],whitelist:[],width:6,wifi:23,will:[],window:[10,16,22,24,25,26,27,28,29,30,31,32],windows_cdk:17,windows_eclips:17,winusb:13,without:[],work:[],workspac:12,write:[8,19],write_data_poll_sem:19,x86_64:10,xshell:23,xtal_ck:6,xxx:[3,5,6,7,9,12],xxx_board:[1,4],xxx_clock_config:1,xxx_close:8,xxx_control:8,xxx_devic:8,xxx_device_t:8,xxx_open:8,xxx_read:8,xxx_regist:8,xxx_write:8,xxxx_case:14,zadig:13,zigbe:18,zxvf:10},titles:["9. ADC \u8bbe\u5907","2. \u65f6\u949f\u6811","10. DAC \u8bbe\u5907","6. DMA \u8bbe\u5907","3. GPIO \u8bbe\u5907","7. I2C \u8bbe\u5907","5. PWM \u8bbe\u5907","8. SPI \u8bbe\u5907","1. API \u5206\u5c42\u6a21\u578b","4. UART \u8bbe\u5907","2.3. Linux OR WSL \u73af\u5883\u5f00\u53d1\u6307\u5357","2.1. Windows \u4e0b\u4f7f\u7528 CDK (\u7c7b MDK Keil)\u5f00\u53d1\u6307\u5357","2.2. Windows \u4e0b\u4f7f\u7528 Eclipse \u5f00\u53d1\u6307\u5357","3. BLDevCube \u70e7\u5f55\u5de5\u5177\u6307\u5357","4. \u57fa\u4e8e cmake \u6846\u67b6\u65b0\u5efa\u5de5\u7a0b\u6307\u5357","5. \u786c\u4ef6\u8fde\u63a5\u6307\u5357","1. \u5f00\u53d1\u524d\u7684\u51c6\u5907","2. \u5f00\u53d1\u73af\u5883\u642d\u5efa\u6307\u5357","BL MCU SDK \u5f00\u53d1\u6307\u5357","4. BLE \u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u4e92\u8fde","5. BOOT2 IAP","2. FATFS \u6587\u4ef6\u7cfb\u7edf\u8bfb\u5199","3. LowPower \u4f4e\u529f\u8017\u8bc4\u4f30","1. SHELL \u547d\u4ee4\u884c\u8c03\u8bd5","9. ADC - \u6309\u952e\u68c0\u6d4b\u7535\u538b","1. GPIO \u8f93\u51fa - \u6d41\u6c34\u706f","3. PWM - \u547c\u5438\u706f","2. GPIO \u4e2d\u65ad - \u6309\u952e\u68c0\u6d4b","6. DMA - RAM\u95f4\u6570\u636e\u642c\u8fd0","7. I2C - AT24CXX \u8bfb\u5199","5. MTIMER - \u5185\u6838\u5b9a\u65f6\u5668","8. SPI - TFT LCD \u663e\u793a","4. UART - \u6570\u636e\u81ea\u6536\u53d1"],titleterms:{adc:[0,24],api:8,at24cxx:29,bl702_avb:15,bl706_iot:15,bl:18,bl_mcu_sdk:[10,11,12],bldevcub:13,ble:[19,23],boot2:20,bouffalo:13,cdk:11,ck:15,client:19,cmake:[10,14],cube:13,dac:2,dev:13,device_clos:[3,6,7,8,9],device_control:[3,6,7,8,9],device_find:8,device_open:[3,5,6,7,8,9],device_read:[7,8,9],device_regist:8,device_set_callback:[3,6,7,8,9],device_unregist:8,device_writ:[7,8,9],dma:[3,28],dma_channel_check_busi:3,dma_channel_start:3,dma_channel_stop:3,dma_channel_upd:3,dma_regist:3,dma_reload:3,eclips:12,exampl:14,fatf:21,gcc:14,gpio:[4,25,27],gpio_attach_irq:4,gpio_irq_en:4,gpio_read:4,gpio_set_mod:4,gpio_toggl:4,gpio_writ:4,hello:[10,11,12],i2c:[5,29],i2c_regist:5,i2c_transf:5,iap:20,jlink:13,keil:11,lab:13,lcd:31,ld:14,link:15,linux:10,lowpow:22,make:10,mcu:18,mdk:11,mtimer:30,openocd:13,option:14,or:10,peripheral_clock_get:1,pwm:[6,26],pwm_channel_start:6,pwm_channel_stop:6,pwm_channel_upd:6,pwm_it_pulse_count_upd:6,pwm_regist:6,ram:28,risc:10,sdk:18,server:19,shell:23,spi:[7,31],spi_rec:7,spi_regist:7,spi_transmit:7,spi_transmit_rec:7,system_clock_get:1,tft:31,uart:[9,13,32],uart_regist:9,window:[11,12],world:[10,11,12],wsl:10,xshell:22}}) \ No newline at end of file +Search.setIndex({docnames:["api_reference/api_adc","api_reference/api_ble","api_reference/api_clock","api_reference/api_dac","api_reference/api_dma","api_reference/api_gpio","api_reference/api_i2c","api_reference/api_pwm","api_reference/api_spi","api_reference/api_structure","api_reference/api_uart","get_started/Linux_quick_start_ubuntu","get_started/Windows_quick_start_cdk","get_started/Windows_quick_start_eclipse","get_started/bl_dev_cube","get_started/cmake_quick_start","get_started/connecting_hardware","get_started/get_started","get_started/index","index","samples/advance samples/ble_scan_demo","samples/advance samples/boot2_iap_info","samples/advance samples/fatfs_demo","samples/advance samples/lowpower_demo","samples/advance samples/shell_demo","samples/basic samples/adc/adc_key_demo","samples/basic samples/adc/index","samples/basic samples/dma/dma_m2m_demo","samples/basic samples/dma/index","samples/basic samples/gpio/blink_demo","samples/basic samples/gpio/button_demo","samples/basic samples/gpio/index","samples/basic samples/i2c/i2c_eeprom_demo","samples/basic samples/i2c/index","samples/basic samples/mtimer/index","samples/basic samples/mtimer/mtimer_demo","samples/basic samples/pwm/index","samples/basic samples/pwm/pwm_breath_demo","samples/basic samples/pwm/pwm_step_motor","samples/basic samples/spi/index","samples/basic samples/spi/spi_lcd_demo","samples/basic samples/uart/index","samples/basic samples/uart/uart_loopback_demo"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":2,sphinx:56},filenames:["api_reference\\api_adc.rst","api_reference\\api_ble.rst","api_reference\\api_clock.rst","api_reference\\api_dac.rst","api_reference\\api_dma.rst","api_reference\\api_gpio.rst","api_reference\\api_i2c.rst","api_reference\\api_pwm.rst","api_reference\\api_spi.rst","api_reference\\api_structure.rst","api_reference\\api_uart.rst","get_started\\Linux_quick_start_ubuntu.rst","get_started\\Windows_quick_start_cdk.rst","get_started\\Windows_quick_start_eclipse.rst","get_started\\bl_dev_cube.rst","get_started\\cmake_quick_start.rst","get_started\\connecting_hardware.rst","get_started\\get_started.rst","get_started\\index.rst","index.rst","samples\\advance samples\\ble_scan_demo.rst","samples\\advance samples\\boot2_iap_info.rst","samples\\advance samples\\fatfs_demo.rst","samples\\advance samples\\lowpower_demo.rst","samples\\advance samples\\shell_demo.rst","samples\\basic samples\\adc\\adc_key_demo.rst","samples\\basic samples\\adc\\index.rst","samples\\basic samples\\dma\\dma_m2m_demo.rst","samples\\basic samples\\dma\\index.rst","samples\\basic samples\\gpio\\blink_demo.rst","samples\\basic samples\\gpio\\button_demo.rst","samples\\basic samples\\gpio\\index.rst","samples\\basic samples\\i2c\\i2c_eeprom_demo.rst","samples\\basic samples\\i2c\\index.rst","samples\\basic samples\\mtimer\\index.rst","samples\\basic samples\\mtimer\\mtimer_demo.rst","samples\\basic samples\\pwm\\index.rst","samples\\basic samples\\pwm\\pwm_breath_demo.rst","samples\\basic samples\\pwm\\pwm_step_motor.rst","samples\\basic samples\\spi\\index.rst","samples\\basic samples\\spi\\spi_lcd_demo.rst","samples\\basic samples\\uart\\index.rst","samples\\basic samples\\uart\\uart_loopback_demo.rst"],objects:{},objnames:{},objtypes:{},terms:{"0v":[0,25],"0x":32,"0x00":[1,32],"0x0000":6,"0x00000000":4,"0x00000001":4,"0x00000002":4,"0x00000003":4,"0x00000006":4,"0x00000007":4,"0x0000000a":4,"0x0000000b":4,"0x00000014":4,"0x00000015":4,"0x00000016":4,"0x00000017":4,"0x00000018":4,"0x00000019":4,"0x0000001a":4,"0x0000001b":4,"0x0000001c":4,"0x0000001d":4,"0x0000001e":4,"0x0000001f":4,"0x0001":6,"0x001":[0,4,6,7,8,9,10],"0x0010":6,"0x0018":1,"0x002":[0,4,6,7,8,9,10],"0x0020":6,"0x0028":1,"0x004":[0,4,6,7,8,9,10],"0x0040":6,"0x008":[0,4,6,7,8,9,10],"0x00a0":1,"0x00f0":1,"0x01":[1,9,20],"0x010":[0,4,6,7,8,9,10],"0x0180":20,"0x02":[9,20],"0x020":[0,4,6,7,8,9,10],"0x03":[9,20],"0x04":[9,20],"0x05":[9,20],"0x06":[9,20],"0x07":[9,20],"0x08":[9,20],"0x09":[9,20],"0x0a":9,"0x0b":9,"0x0c":9,"0x0d":9,"0x0e":9,"0x0f":9,"0x10":[0,4,7,8,10],"0x1000":9,"0x11":[0,4,10],"0x12":[0,4,20],"0x13":[0,4,20],"0x14":0,"0x15":0,"0x16":0,"0x18":20,"0x1812":20,"0x2000":9,"0x3000":9,"0x50":32,"0x71":20,"0x80":20,"0xff":27,"10":[5,11,20,23],"100":7,"1000":25,"1000000":[35,37],"11":[5,20],"12":[0,5,20],"125hz":38,"12bit":0,"13":[1,5,20],"14":[0,20,23],"14bit":0,"15":[6,20,32],"16":[0,4,7,20,37],"160":38,"16bit":0,"17":20,"18":[17,20],"18000000":8,"19":[11,20],"1m":35,"1mhz":37,"1s":[23,35],"1v":25,"20":20,"2000000":[10,11,24,42],"20210120":11,"244":20,"25hz":38,"28":23,"28byj48":38,"2f":25,"2m":14,"2mhz":0,"2v":[0,25],"31":23,"32":[4,27,37,38],"32768":23,"32k":[7,23,38],"32m":[23,37],"360":38,"36000000":40,"37":38,"3v":25,"3v3":16,"400":1,"4096":38,"40m":8,"43v":25,"4ghz":1,"4k":23,"50":[7,37],"625":[1,38],"64":[35,38],"64k":23,"68":23,"8000":27,"break":10,"case":[13,15],"char":[0,1,4,6,7,8,9,10,20],"const":[0,1,4,6,7,8,9,10,20],"default":16,"enum":[0,1,2,4,6,7,8,9,10,38],"export":11,"for":[1,11,27,37],"function":[1,24,25,29,30,32,37,38,40,42],"if":[0,1,4,6,7,8,10,20,24,25,27,32,37,38,40,42],"import":13,"in":[1,20,21],"int":[0,1,4,5,6,7,8,9,10,20],"null":[0,1,4,7,8,9,10,20,24,27,42],"public":1,"return":[0,1,4,5,6,7,8,9,10,20],"static":[0,4,6,7,8,10,20,30,35],"try":1,"void":[0,1,4,5,7,8,9,10,20,24,25,27,30,35,38,40,42],"while":[20,23],"with":1,access:[1,4],acknowledg:1,acl:1,activ:1,ad:1,ad_discov:1,ad_len:1,adc0:[0,4,25],adc0_config:[0,25],adc0_index:[0,25],adc:[9,19],adc_channel_cfg:25,adc_channel_cfg_t:[0,25],adc_channel_start:25,adc_clk_div_t:0,adc_clock_div_32:[0,25],adc_data_width_16b_with_256_averag:[0,25],adc_data_width_t:0,adc_dev:[0,25],adc_devic:0,adc_device_t:0,adc_event_fifo_readi:0,adc_event_overrun:0,adc_event_typ:0,adc_event_underrun:0,adc_fifo_threshold_1byt:[0,25],adc_fifo_threshold_t:0,adc_gain_1:[0,25],adc_index_typ:0,adc_it_typ:0,adc_kei:25,adc_max_index:0,adc_param_cfg_t:0,adc_pga_gain_t:0,adc_regist:25,adc_start:0,adc_stop:0,adc_vref_3p2v:[0,25],adc_vref_t:0,adcx_devic:0,add:12,addr:1,addr_typ:1,address:1,adv:[1,20],adv_addr:1,adv_data:20,adv_nam:20,adv_param:20,advanc:14,advertis:1,after:1,alia:24,all:[14,17],an:1,analog:0,and:1,ani:1,aon:23,api:19,app:[11,13,15,20,23,24,25,27,29,30,32,35,37,38,40,42],appear:1,appli:13,applic:[1,13,21],apt:[11,17],are:1,arg:[0,4,7,8,9,10,24,27,42],array_s:20,as:[1,20],asynchron:10,at24cxx:33,atomic_defin:1,atomic_t:1,attr:20,attribut:1,avb:16,bashrc:11,baudrat:[10,24,42],bclk:7,be:[1,20],bearer:1,befor:1,bflb_mcu_prefer:13,bflb_platform_delay_m:37,bflb_platform_init:[24,42],bflb_platform_set_alarm_tim:35,bin:[11,12,13,14,21],bit:[0,1,7,10],bl602:1,bl702:[11,12,13,17,19,20],bl702_avb:40,bl702_bl704_bl706_ds_en_combo_1:23,bl702_driver:40,bl702_iot:16,bl706:[13,16,21,23],bl706_avb:[17,25,40],bl706_iot:[11,13,15,17,20,24,25,27,29,30,32,35,37,38,42],bl706_lp:23,bl70x:[16,19,23],bl70x_flash:12,bl70x_flasher:12,bl:[5,12,23],bl_clean:13,bl_make:13,bl_mcu_sdk:[9,15,20,21,23,24,25,27,29,30,32,35,37,38,40,42],bl_test_01:20,bldevcub:[12,19,20,24,25,27,29,30,32,35,37,38,40,42],ble:19,ble_centr:20,ble_controller_init:1,ble_peripher:20,ble_start_adv:20,ble_start_scan:20,ble_tp_conn:20,ble_tp_conn_callback:20,ble_tp_connect:20,ble_tp_disconnect:20,ble_tp_init:20,ble_tp_notify_task:20,ble_tp_recv_wr:20,ble_write_data:20,ble_write_data_task:20,bluetooth:1,board:[0,2,4,5,6,7,8,10,11,13,15,16,20,23,24,25,27,29,30,32,35,37,38,40,42],board_get_debug_uart_index:[24,42],bool:[0,1],boot2:19,boot2_iap:21,boot:[11,14,16,17],boot_rom:11,borad:13,bouffalo:[13,16,17,21],bouffalolab:[11,12,13,14],boufflao:23,br:1,breath:37,broadcast:1,brows:14,bsp:[0,2,4,5,6,7,8,10,24,25,27,32,37,38,40,42],bsp_adc_clock_div:25,bsp_adc_clock_sourc:25,bsp_i2c_clock_div:32,bsp_i2c_clock_sourc:32,bsp_pwm_clock_div:[37,38],bsp_pwm_clock_sourc:[37,38],bsp_spi_clock_div:40,bsp_spi_clock_sourc:40,bsp_uart_clock_div:[24,42],bsp_uart_clock_sourc:[24,42],bsp_using_adc0:[0,25],bsp_using_dma0_ch0:[4,27],bsp_using_dma0_ch1:4,bsp_using_dma0_ch2:4,bsp_using_dma0_ch3:4,bsp_using_dma0_ch4:4,bsp_using_dma0_ch5:4,bsp_using_dma0_ch6:4,bsp_using_dma0_ch7:4,bsp_using_dma_ch0:4,bsp_using_i2c0:[6,32],bsp_using_pwm_ch0:[7,38],bsp_using_pwm_ch1:[7,38],bsp_using_pwm_ch2:[7,37,38],bsp_using_pwm_ch3:[7,38],bsp_using_pwm_ch4:7,bsp_using_spi0:[8,40],bsp_using_uart0:[10,24,42],bsp_using_uart1:10,bt:1,bt_addr_le_ani:1,bt_addr_le_t:1,bt_char_ble_tp_not_attr_val_index:20,bt_conn:[1,20],bt_conn_auth_cancel:1,bt_conn_auth_cb:1,bt_conn_auth_cb_regist:1,bt_conn_auth_passkey_confirm:1,bt_conn_auth_passkey_entri:1,bt_conn_auth_pincode_entri:1,bt_conn_br:1,bt_conn_cb:[1,20],bt_conn_cb_regist:[1,20],bt_conn_create_auto_l:1,bt_conn_create_auto_stop:1,bt_conn_create_l:1,bt_conn_create_slave_l:1,bt_conn_disconnect:1,bt_conn_enc_key_s:1,bt_conn_get_info:1,bt_conn_get_remote_dev_info:1,bt_conn_get_secur:1,bt_conn_info:1,bt_conn_l:1,bt_conn_le_param_upd:1,bt_conn_num_flag:1,bt_conn_rv:1,bt_conn_sco:1,bt_conn_set_secur:1,bt_conn_state_t:1,bt_data:[1,20],bt_data_byt:1,bt_data_flag:[1,20],bt_data_gap_appear:20,bt_data_manufacturer_data:20,bt_data_name_complet:[1,20],bt_data_uuid16_al:20,bt_enabl:1,bt_gap_adv_fast_int_max_3:20,bt_gap_adv_fast_int_min_3:20,bt_gap_init_conn_int_max:1,bt_gap_init_conn_int_min:1,bt_gap_scan_slow_interval_1:1,bt_gap_scan_slow_window_1:1,bt_gatt_attr:20,bt_gatt_notifi:20,bt_gatt_subscribe_param:20,bt_gatt_write_without_respons:20,bt_get_local_address:1,bt_le_ad_gener:1,bt_le_ad_limit:20,bt_le_ad_no_bredr:[1,20],bt_le_adv_opt_connect:1,bt_le_adv_opt_dir_addr_rpa:1,bt_le_adv_opt_dir_mode_low_duti:1,bt_le_adv_opt_filter_conn:1,bt_le_adv_opt_filter_scan_req:1,bt_le_adv_opt_non:1,bt_le_adv_opt_one_tim:1,bt_le_adv_opt_use_ident:1,bt_le_adv_opt_use_nam:1,bt_le_adv_param:[1,20],bt_le_adv_start:[1,20],bt_le_adv_stop:1,bt_le_adv_update_data:1,bt_le_conn_param:1,bt_le_read_rssi:1,bt_le_scan_cb_t:1,bt_le_scan_param:1,bt_le_scan_start:1,bt_le_scan_stop:1,bt_le_scan_type_act:1,bt_le_scan_type_pass:1,bt_le_set_auto_conn:1,bt_le_set_chan_map:1,bt_le_whitelist_add:1,bt_le_whitelist_clear:1,bt_le_whitelist_rem:1,bt_ready_cb_t:1,bt_security_t:1,bt_set_bond:1,bt_set_tx_pwr:1,bt_unpair:1,bt_warn:20,buf:[6,20,32],buffer:[0,8,9,10],build:[11,12,13],bus:8,but:1,by:1,call:1,callback:[0,1,4,7,8,9,10,20],can:1,cancel:13,canon:11,care:1,cb:1,cbfun:5,ccw:38,cd:[11,20,24,25,27,29,30,32,35,37,38,40,42],cdk:[17,20,23,24,25,27,29,30,32,35,37,38,40,42],cdk_flashload:12,cdkproj:[12,24,25,27,29,30,32,35,37,38,40,42],central:1,cfg:7,ch8:25,ch:[4,6,7,27,37,38],chan_map:1,channel:1,char_hdl:20,characterist:1,check:1,chip:14,circuit:6,ck:[12,17],ck_link:16,ck_link_debug:12,clean:12,clear:9,click:14,client:1,clk:[8,40],clk_div:[0,25],clk_phase:[8,40],clk_polara:[8,40],clock:[14,23],clock_config:[24,25,32,37,38,40,42],clock_period:23,clone:[11,12,13],close:9,cmake:19,cmake_current_source_dir:15,cmakelist:15,cmd:[0,4,7,8,9,10],code:9,com:[11,12,13,14,16,17],command:[13,24],complet:[1,20],compromis:1,config:9,config_bt_bredr:1,config_bt_privaci:1,config_bt_remote_vers:1,config_bt_smp:1,config_bt_stack_pt:1,config_gpio10_func:38,config_gpio11_func:[32,38],config_gpio12_func:38,config_gpio14_func:[24,42],config_gpio15_func:[24,42],config_gpio16_func:32,config_gpio18_func:25,config_gpio19_func:40,config_gpio20_func:40,config_gpio21_func:40,config_gpio22_func:37,config_gpio3_func:38,configur:9,conn:[1,20],connect:[1,16,20],consol:13,continuous_conv_mod:[0,25],control:[1,9],conveni:1,convert:[0,17],core:19,count:7,cp:11,cpha:8,cpol:8,cpu:[12,23],creat:14,cs1:40,cs1_high:40,cs1_low:40,cs:8,csky:12,ctrl:9,cts:10,cube:[12,16,21],cw:38,d0:29,d1:29,d2:29,d3:29,dac0:4,dac:[0,19],data:[1,10,20,24,40],data_appear:20,data_len:1,data_manu:20,data_uuid:20,data_width:[0,25],databit:[10,24,42],datas:[8,40],datasheet:23,dc12v:38,dc5v:38,dc:40,dc_high:40,debug:[12,13],debug_log:[24,42],debugg:[11,12,14,17],default_config:40,defer:1,defin:[0,1,4,5,6,7,8,9,10,24,25,27,32,37,38,40,42],deivce_ctrl_pwm_dutycycle_config:[7,37,38],deivce_ctrl_pwm_frequence_config:7,deivce_ctrl_pwm_it_pulse_count_config:7,delai:1,demo:[13,20,24,25,27,29,30,32,35,37,38,40,42],desc:24,descript:[0,4,7,8,10],determin:1,dev:[0,1,4,6,7,8,9,10,11,12,13,16,17,21,24,27,42],devcub:21,devic:[0,1,4,6,7,8,9,10,14,17,24,25,27,32,37,42],device_class_adc:9,device_class_camera:9,device_class_dma:9,device_class_gpio:9,device_class_i2:9,device_class_i2c:9,device_class_non:9,device_class_pwm:9,device_class_sdio:9,device_class_sec_hash:9,device_class_spi:9,device_class_tim:9,device_class_typ:9,device_class_uart:9,device_class_usb:9,device_clos:40,device_contorl:[37,38],device_control:[24,25,27,37,38,42],device_ctrl_adc_channel_config:[0,25],device_ctrl_adc_channel_start:0,device_ctrl_adc_channel_stop:0,device_ctrl_adc_tsen_off:0,device_ctrl_adc_tsen_on:0,device_ctrl_adc_vbat_off:0,device_ctrl_adc_vbat_on:0,device_ctrl_attach_rx_dma:[0,8,9,10],device_ctrl_attach_tx_dma:[8,9,10],device_ctrl_clr_int:[0,4,7,8,9,10,24,42],device_ctrl_config:[0,7,9,10],device_ctrl_get_config:9,device_ctrl_get_int:9,device_ctrl_resum:[7,8,9],device_ctrl_resvd1:9,device_ctrl_resvd2:9,device_ctrl_rx_dma_resum:[8,9,10],device_ctrl_rx_dma_suspend:[8,9,10],device_ctrl_set_int:[0,4,7,8,9,10,24,27,42],device_ctrl_spi_config_clock:8,device_ctrl_suspend:[7,8,9],device_ctrl_tx_dma_resum:[8,9,10],device_ctrl_tx_dma_suspend:[8,9,10],device_ctrl_uart_get_rx_fifo:10,device_ctrl_uart_get_tx_fifo:10,device_find:[24,25,27,32,37,38,40,42],device_found:20,device_oflag_dma_rx:[0,4,6,7,8,9,10],device_oflag_dma_tx:[0,4,6,7,8,9,10],device_oflag_int_rx:[0,4,6,7,8,9,10,24,42],device_oflag_int_tx:[0,4,6,7,8,9,10],device_oflag_rdonli:9,device_oflag_rdwr:[9,24,27,32,37,38,40,42],device_oflag_stream_rx:[0,4,6,7,8,9,10,25,40],device_oflag_stream_tx:[0,4,6,7,8,9,10,24,37,38,40,42],device_oflag_wronli:9,device_open:[24,25,27,32,37,38,40,42],device_read:25,device_set_callback:[24,27,42],device_status_typ:9,device_writ:42,differential_mod:[0,25],digit:0,dir:38,direct:[1,4,8,27,40],disabl:[0,7,25,38],disconnect:[1,20],displai:40,dl:[14,17],dlist_t:9,dma0_ch0_config:[4,27],dma0_ch0_index:[4,27],dma0_ch1_config:4,dma0_ch1_index:4,dma0_ch2_config:4,dma0_ch2_index:4,dma0_ch3_config:4,dma0_ch3_index:4,dma0_ch4_config:4,dma0_ch4_index:4,dma0_ch5_config:4,dma0_ch5_index:4,dma0_ch6_config:4,dma0_ch6_index:4,dma0_ch7_config:4,dma0_ch7_index:4,dma:[0,6,7,8,9,10,19],dma_burst_16byt:4,dma_burst_1byt:4,dma_burst_4byt:4,dma_burst_8byt:4,dma_ch0:27,dma_ch0_index:4,dma_channel_get_statu:4,dma_channel_start:27,dma_dev:4,dma_devic:4,dma_device_t:4,dma_dst_buff:27,dma_event_complet:4,dma_event_typ:4,dma_index_typ:4,dma_lli_ctrl_t:4,dma_lli_cycle_mod:4,dma_lli_once_mod:[4,27],dma_m2m:27,dma_max_index:4,dma_memory_to_memori:[4,27],dma_memory_to_periph:4,dma_periph_to_memori:4,dma_periph_to_periph:4,dma_regist:27,dma_reload:27,dma_request_adc0:4,dma_request_dac0:4,dma_request_i2c0_rx:4,dma_request_i2c0_tx:4,dma_request_i2s_rx:4,dma_request_i2s_tx:4,dma_request_non:[4,27],dma_request_spi0_rx:4,dma_request_spi0_tx:4,dma_request_uart0_rx:4,dma_request_uart0_tx:4,dma_request_uart1_rx:4,dma_request_uart1_tx:4,dma_request_usb_ep0:4,dma_request_usb_ep1:4,dma_request_usb_ep2:4,dma_request_usb_ep3:4,dma_request_usb_ep4:4,dma_request_usb_ep5:4,dma_request_usb_ep6:4,dma_request_usb_ep7:4,dma_src_buff:27,dma_transfer_dir_typ:4,dma_transfer_don:27,dma_transfer_width_16bit:4,dma_transfer_width_32bit:[4,27],dma_transfer_width_8bit:4,dmax_devic:4,don:1,done:27,download:[11,12,13,14],driver:[14,17,40],dst_addr:4,dst_burst_siz:4,dst_req:[4,27],dst_width:[4,27],dtcm:23,duti:1,dutycycl:37,e24:19,echo:11,eclips:17,edit:13,eeprom:32,effect:1,elf:[11,12,13],els:[25,38,40,42],enabl:[1,5,25,30,38],encrypt:1,endif:[0,1,4,6,7,8,10,24,25,27,32,37,38,40,42],ep0:4,ep1:4,ep2:4,ep3:4,ep4:4,ep5:4,ep6:4,ep7:4,epf:13,err:[1,20],error:[1,20,27],even:[1,10],event:[0,4,7,8,9,10],exampl:[11,12,13,20,21,23,24,25,27,29,30,32,35,37,38,40,42],exe:[12,13,14,17],exist:13,fail:25,fatf:19,featur:1,field:1,fifo:[0,8,10,42],fifo_threshold:[0,8,10,24,25,40,42],file:[11,13,14],filter:1,filter_dup:1,find:[24,25,27,32,37,38,40,42],finish:[13,14],finsh:13,flag:[0,1,4,6,7,8,9,10,20,32],flash:[12,14,21],flashdownload:12,freerto:15,frequenc:[37,38],friend:1,ftdi:17,func1:16,func2:16,gain:[0,25],gap:1,gate:23,gatt:1,gdb:13,gener:[1,5,13],generate_bin:15,get:9,get_adc_key_valu:25,get_attr:20,git:[11,12,13],gite:[11,12,13],gnd:[13,16],gpio10:[38,40],gpio11:[30,32,38],gpio11_int_callback:30,gpio12:38,gpio14:[24,42],gpio15:[24,42],gpio16:32,gpio18:25,gpio19:40,gpio20:40,gpio21:40,gpio22:[29,37,40],gpio29:29,gpio30:29,gpio31:29,gpio3:38,gpio:[13,19,23,24,25,32,37,38,40,42],gpio_async_falling_triger_int_mod:5,gpio_async_high_level_int_mod:5,gpio_async_low_level_int_mod:5,gpio_async_rising_triger_int_mod:5,gpio_attach_irq:30,gpio_blink:[13,29],gpio_cas:15,gpio_fun_adc:25,gpio_fun_i2c:32,gpio_fun_pwm:[37,38],gpio_fun_spi:40,gpio_fun_uart0_rx:[24,42],gpio_fun_uart0_tx:[24,42],gpio_input_mod:5,gpio_input_pd_mod:5,gpio_input_pp_mod:5,gpio_int:30,gpio_irq_en:30,gpio_output_mod:[5,40],gpio_output_pd_mod:5,gpio_output_pp_mod:[5,29],gpio_pin_11:30,gpio_pin_22:29,gpio_pin_29:29,gpio_pin_30:29,gpio_pin_31:29,gpio_set_mod:[29,30,40],gpio_sync_falling_triger_int_mod:5,gpio_sync_high_level_int_mod:5,gpio_sync_low_level_int_mod:5,gpio_sync_rising_triger_int_mod:[5,30],gpio_test_cas:15,gpio_writ:[29,40],guest:14,gz:11,hal:9,hal_adc:0,hal_dma:4,hal_drv:40,hal_i2c:6,hal_pwm:7,hal_spi:8,hal_uart:10,handl:[1,9],happen:1,hardwar:1,hbn:23,hci:1,hci_driver_init:1,hd12:16,hd1:16,hd3:16,hd8:16,hello:24,hellowd:[11,12,13,24],helloworld:[11,12,13],hellwd:24,help:12,here:14,high:1,host:1,http:[11,12,13,14,17],i2c0:[6,32],i2c0_config:[6,32],i2c0_index:[6,32],i2c1:6,i2c:[4,19],i2c_at24cxx:32,i2c_dev:6,i2c_devic:6,i2c_device_t:6,i2c_hw_mod:[6,32],i2c_index_typ:6,i2c_max_index:6,i2c_msg:6,i2c_msg_t:[6,32],i2c_rd:[6,32],i2c_regist:32,i2c_scl:32,i2c_sda:32,i2c_transf:32,i2c_wr:[6,32],i2cx_devic:6,i2s:[4,16],iap:19,id:[1,4,6,8,10,24,27,32,40,42],ident:1,identifi:1,ifdef:[0,4,6,7,8,10],ifndef:[0,4,6,7,8,10,24,25,27,32,37,38,40,42],imag:14,incom:1,index:[0,4,6,7,8,10,27],indic:1,info:1,input:5,instal:[11,17],int8_t:1,inter:6,interfac:[8,11,14,17],intergr:6,interrupt:9,interv:1,interval_max:[1,20],interval_min:[1,20],into:13,iot:[13,16,19],is:[1,10],isregist:20,it:1,it_pulse_count:[7,37,38],itcm:23,its:1,jlink:[16,17],jlink_bl_mcu_sdk:13,jtag:[14,16,17,19],jtag_tck:16,jtag_tdi:16,jtag_tdo:16,jtag_tm:16,k_delayed_work:1,k_fifo:1,k_forev:20,k_sem_giv:20,k_sem_tak:20,k_work:1,keep:1,kei:[1,25],keil:[24,25,27,29,30,32,35,37,38,40,42],key_no_valu:25,keyvalu:25,l2cap:1,lab:[13,16,17,21,23],latenc:1,launch:13,lcd:39,lcd_c:40,lcd_cs_pin:40,lcd_dc:40,lcd_dc_pin:40,lcd_wr_byte:40,lcd_wr_halfword:40,lcd_wr_word:40,le:1,led:[17,37],led_breath:37,len:[6,20,32],length:[8,10,20],level:[1,23],libftdi:17,libhidapi:17,libusb:17,lin:10,link:[12,13,17],linker_script:15,linux:[17,18,23,24],list:[4,9,14,17],ll:1,lli:4,lli_cfg:4,loader:12,local:1,log:13,low:1,lowpow:19,lowpower_test:23,lpn:1,lsb:8,lsusb:17,lts:17,ma:23,main:[11,13,15],maix:[14,17],make:[13,15,20,23,24,25,27,29,30,32,35,37,38,40,42],manag:1,manufactur:1,map:1,maximum:1,mcu:[0,4,5,6,7,8,10,11,12,13,14,16,17,23],mdk:[24,25,27,29,30,32,35,37,38,40,42],meaning:1,media:11,memori:[4,27],mesh:1,mini:[11,14,16],minimum:1,miso:40,mkdir:11,mobaxterm:24,mode:[1,5,6,8,32,40],modul:7,mosi:40,motor_ch0:38,motor_ch1:38,motor_ch2:38,motor_ch3:38,motor_dir_typ:38,motor_set_dir:38,ms:1,msb:8,msg:[6,24,25,27,30,32,35,42],mtimer:19,must:[1,20],mv:25,my_cas:15,name:[0,1,4,6,7,8,9,10,20],name_max:9,need:1,neg_channel:25,negchlist:25,net_buf:1,next:[1,13],no:[1,10],node:[1,9],none:4,not:1,notif:20,notifi:[1,20],notify_func:20,notify_poll_sem:20,num:6,observ:1,occ:12,occur:1,ocram:23,octam:23,odd:10,of:[1,9],ofast:15,offset:20,oflag:[0,4,6,7,8,9,10],ok:12,one:[10,20],onli:1,oob:1,open:[9,25],openocd:[12,17],openocd_debug:12,option:[1,14,17,20],or:[1,12,14,16,20,24],org:11,os:35,osr:0,ostrac:12,other:1,otherwis:1,out:13,outgo:1,output:5,over:13,own:1,own_address_typ:1,packet:1,page:23,pair:1,pane:12,param:[1,20],paramet:1,parent:[0,4,6,7,8,9,10],pariti:[10,24,42],passkei:1,path:11,pb:1,pc:[13,16,17,23,24],pdf:23,pds:23,peer:1,pending_no_cb:1,period:[7,37,38],peripher:[1,4,8,12],peripheral_clock_adc:2,peripheral_clock_dac:2,peripheral_clock_i2:2,peripheral_clock_i2c:2,peripheral_clock_spi:2,peripheral_clock_typ:2,peripheral_clock_uart:2,peripheral_config:[0,4,6,7,8,10,24,25,27,32,37,38,40,42],phase:[6,32],picocom:11,pin:[1,5,24,25,29,30,32,37,38,40,42],pinmux:5,pinmux_config:[5,24,25,37,38,40,42],pinmux_lvgl:40,pinmux_select:40,pix:16,plu:[12,17],polarity_invert_mod:[7,38],port:14,pos:[0,8,9,10],pos_channel:25,poschlist:25,power:[1,23],prefer:13,press:25,privaci:1,privat:1,profil:[1,12],program:[14,21],project:[12,13],provid:1,provis:1,proxi:1,psram:14,puls:7,purpos:5,pvparamet:20,pwm:[4,19],pwm_breath_l:37,pwm_cfg:[37,38],pwm_ch0:38,pwm_ch0_config:[7,38],pwm_ch0_index:[7,38],pwm_ch1:38,pwm_ch1_config:[7,38],pwm_ch1_index:[7,38],pwm_ch2:[37,38],pwm_ch2_config:[7,37,38],pwm_ch2_index:[7,37,38],pwm_ch3:38,pwm_ch3_config:[7,38],pwm_ch3_index:[7,38],pwm_ch4_config:7,pwm_ch4_index:7,pwm_channel_start:[37,38],pwm_config_t:7,pwm_dev:[7,37,38],pwm_devic:7,pwm_device_t:7,pwm_dutycycle_config_t:[7,38],pwm_event_complet:7,pwm_event_typ:7,pwm_index_typ:7,pwm_max_index:7,pwm_regist:[37,38],pwm_step_motor:38,pwmx_devic:7,queue:1,radio:1,ram:[23,28],random:1,rang:1,read:[1,9,32],reason:1,receiv:10,recurs:[11,12,13],recv_buf:8,ref:1,refresh:[14,16],regist:12,relai:1,remot:1,replac:[14,17],request:[1,4],requir:1,required_sec_level:1,resolut:1,resolv:1,resourc:1,respons:1,result_v:25,resum:[1,9],rf:11,risc:[13,19,35],riscv64:11,rise:30,role:1,rom:[14,16],root_clock_source_bclk:[32,40],root_clock_source_pll_96m:[24,42],root_clock_source_rc_32k:38,root_clock_source_xclk:[25,37],rpa:1,rssi:1,rst:[11,12,13,14,16],rtc:23,rto:[10,42],rts:10,run:23,rv:[1,11,12,14,17],rx0:16,rx:[1,4,8,10,23],rx_dma:[8,10],rx_fifo:42,rx_len:1,rxd0:13,rxd:16,same:20,scan:1,scan_param:1,scan_rsp:1,sclk:8,sco:1,sd:1,sd_len:1,sdi:8,sdk:[5,11,12,13,15],sdk_path:[20,24,25,27,29,30,32,35,37,38,40,42],sdo:8,sec:1,sec_level:1,secur:1,segger:[13,14],select:14,send:20,send_buf:8,sent:1,serial:[8,12,17],server:1,servic:[1,20],set:[1,9,12,15],setup:12,shell:19,shell_cmd_export:24,shell_cmd_export_alia:24,shell_handl:24,shell_init:24,shell_irq_callback:24,show:14,sifiv:19,simpl:1,sipe:[11,12,14,17],size:[0,4,7,8,9,10,24,27,42],size_t:1,sizeof:20,sky:12,slave:1,slaveaddr:[6,32],sleeptim:23,smp:1,so:1,solicit:1,sourc:11,spec:23,specif:1,specifi:1,speed:14,spi0:[8,40],spi0_config:[8,40],spi0_index:[8,40],spi:[4,9,16,19],spi_config:40,spi_datasize_16bit:8,spi_datasize_24bit:8,spi_datasize_32bit:8,spi_datasize_8bit:[8,40],spi_dev:8,spi_devic:8,spi_device_t:8,spi_event_rx_fifo:8,spi_event_tx_fifo:8,spi_event_typ:8,spi_event_unknown:8,spi_index_typ:8,spi_lcd:40,spi_lsb_byte0_direction_first:8,spi_lsb_byte3_direction_first:8,spi_master_mod:[8,40],spi_max_index:8,spi_miso:40,spi_mosi:40,spi_msb_byte0_direction_first:[8,40],spi_msb_byte3_direction_first:8,spi_phase_1edg:[8,40],spi_phase_2edg:8,spi_polarity_high:8,spi_polarity_low:[8,40],spi_regist:40,spi_sck:40,spi_slvae_mod:8,spi_swap_en:40,spi_transfer_tpye_24bit:8,spi_transfer_type_16bit:[8,40],spi_transfer_type_32bit:[8,40],spi_transfer_type_8bit:[8,40],spi_transmit:40,spix_devic:8,src_addr:4,src_burst_siz:4,src_req:[4,27],src_width:[4,27],stack:1,start:12,state:[1,24,27,42],statu:9,std:9,step:13,stop:[1,10,12,38],stopbit:[10,24,42],strlen:20,struct:[0,1,4,6,7,8,9,10,20,24,27,32,37,42],structur:9,sub_addr_0byt:6,sub_addr_1byt:[6,32],sub_addr_2byt:6,subaddr:[6,32],subsystem:11,subvers:1,success:[12,14,27,32],sudo:11,support:1,support_bl:20,support_float:20,support_freerto:[15,20],support_shel:[23,24],suspend:9,sw1:[25,30],sw5:25,sync:10,sys_slist_t:1,system:12,system_clock_bclk:2,system_clock_fclk:2,system_clock_root_clock:2,system_clock_typ:2,system_clock_xclk:2,systick:35,systick_isr:35,tabl:5,take:1,taken:1,tar:11,target:[1,13],target_required_lib:15,target_required_private_opt:15,target_required_src:15,task:[1,27],task_prior:1,tck:16,tdi:16,tdo:16,termin:17,test1:15,test2:15,test:24,tft:39,that:1,the:[1,20],thi:[1,20],threshold_high:[7,37,38],threshold_low:[7,37,38],tick:35,time:20,timeout:1,tk:1,tms:16,to:[0,1,4,14,20,27],togeth:1,tool:[12,14,17],tp:20,tp_wr_hdl:20,transfer:[4,27],transfer_mod:[4,27],transfer_s:4,transmitt:10,trigger:30,ttl:[11,12,13,16,21,23],ttyusb0:11,two:10,tx0:16,tx:[1,4,8,10],tx_complet:1,tx_complete_work:1,tx_dma:[8,10],tx_mtu_siz:20,tx_pend:1,tx_queue:1,txd0:13,txd:16,txt:15,tyep:4,type:[1,2,8,9,12,13,14,16,17],typedef:[0,4,6,7,8,9,10],u16_t:[1,20],u32_t:1,u8_t:[1,20],ua:23,uart0:[4,10,16,24,42],uart0_config:[10,24,42],uart0_index:10,uart0_rx:[24,42],uart0_tx:[24,42],uart1:4,uart1_config:10,uart1_index:10,uart:[11,19,23,24],uart_data_len_5:10,uart_data_len_6:10,uart_data_len_7:10,uart_data_len_8:[10,24,42],uart_databits_t:10,uart_dev:10,uart_devic:10,uart_device_t:10,uart_echo:42,uart_event_rto:[10,42],uart_event_rx_end:10,uart_event_rx_fifo:[10,24,42],uart_event_tx_end:10,uart_event_tx_fifo:10,uart_event_typ:10,uart_event_unknown:10,uart_index_typ:10,uart_irq_callback:42,uart_it_typ:10,uart_max_index:10,uart_par_even:10,uart_par_non:[10,24,42],uart_par_odd:10,uart_param_cfg_t:10,uart_parity_t:10,uart_regist:[24,42],uart_rto_it:42,uart_rx_fifo_it:[24,42],uart_stop_on:[10,24,42],uart_stop_one_d_f:10,uart_stop_two:10,uart_stopbits_t:10,uartx_devic:10,ubuntu:[11,17],uint16_t:[0,4,6,7,8,9,10,40],uint32_t:[0,2,4,5,6,7,8,9,10,24,27,30,35,40,42],uint8_t:[0,1,4,5,6,7,8,10,20,24,32,40,42],uln2003:38,undirect:20,uniform:1,union:1,univers:10,unknow:20,unsign:1,updat:[1,11],update_work:1,upload:11,usart:21,usb:[4,11,12,13,14,16,17,21,23,24],use:1,used:1,user:21,uses:1,using:1,usr:11,uuid:1,v10:14,v11:[14,17],v3:11,valu:[1,5],vbat:0,vdd33:16,vdd:[0,16],version:1,vi:11,view:[12,14],viewer:12,volt:25,vref:[0,16,25],vtref:16,warn:1,we:1,welcom:13,wfi:23,wget:11,when:1,which:1,whitelist:1,width:7,wifi:24,will:1,win:17,window:[1,11,17,23,24,25,27,29,30,32,35,37,38,40,42],windows_cdk:18,windows_eclips:18,winusb:[14,17],without:1,work:1,workspac:13,world:24,write:[9,20],write_data_poll_sem:20,x86_64:11,xshell:24,xtal_ck:7,xxx:[0,4,6,7,8,10,13],xxx_board:[2,5],xxx_clock_config:2,xxx_close:9,xxx_control:9,xxx_devic:9,xxx_device_t:9,xxx_open:9,xxx_read:9,xxx_regist:9,xxx_write:9,xxxx_case:15,zadig:[14,17],zigbe:19,zxvf:11},titles:["9. ADC \u8bbe\u5907","BLE","2. \u65f6\u949f\u6811","10. DAC \u8bbe\u5907","6. DMA \u8bbe\u5907","3. GPIO \u8bbe\u5907","7. I2C \u8bbe\u5907","5. PWM \u8bbe\u5907","8. SPI \u8bbe\u5907","1. API \u5206\u5c42\u6a21\u578b","4. UART \u8bbe\u5907","2.3. Linux OR WSL \u73af\u5883\u5f00\u53d1\u6307\u5357","2.1. Windows \u4e0b\u4f7f\u7528 CDK (\u7c7b MDK Keil)\u5f00\u53d1\u6307\u5357","2.2. Windows \u4e0b\u4f7f\u7528 Eclipse \u5f00\u53d1\u6307\u5357","3. BLDevCube \u70e7\u5f55\u5de5\u5177\u6307\u5357","4. \u57fa\u4e8e cmake \u6846\u67b6\u65b0\u5efa\u5de5\u7a0b\u6307\u5357","5. \u786c\u4ef6\u8fde\u63a5\u6307\u5357","1. \u5f00\u53d1\u524d\u7684\u51c6\u5907","2. \u5f00\u53d1\u73af\u5883\u642d\u5efa\u6307\u5357","BL MCU SDK \u5f00\u53d1\u6307\u5357","4. BLE \u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u4e92\u8fde","5. BOOT2 IAP","2. FATFS \u6587\u4ef6\u7cfb\u7edf\u8bfb\u5199","3. LowPower \u4f4e\u529f\u8017\u8bc4\u4f30","1. SHELL \u547d\u4ee4\u884c\u8c03\u8bd5","8.1. ADC - \u6309\u952e\u68c0\u6d4b\u7535\u538b","8. ADC \u793a\u4f8b","5.1. DMA - RAM\u95f4\u6570\u636e\u642c\u8fd0","5. DMA \u793a\u4f8b","1.1. GPIO \u8f93\u51fa - \u6d41\u6c34\u706f","1.2. GPIO \u4e2d\u65ad - \u6309\u952e\u68c0\u6d4b","1. GPIO \u793a\u4f8b","7.1. I2C - AT24CXX \u8bfb\u5199","7. I2C \u793a\u4f8b","4. MTIMER \u793a\u4f8b","4.1. MTIMER - \u7cfb\u7edf\u5b9a\u65f6\u5668","3. PWM \u793a\u4f8b","3.1. PWM - \u547c\u5438\u706f","3.2. PWM - \u9a71\u52a8\u6b65\u8fdb\u7535\u673a","6. SPI \u793a\u4f8b","6.1. SPI - TFT LCD \u663e\u793a","2. UART \u793a\u4f8b","2.1. UART - \u6570\u636e\u81ea\u6536\u53d1"],titleterms:{adc:[0,25,26],adc_regist:0,api:[1,9],at24cxx:32,bl706_avb:16,bl706_iot:16,bl:19,bl_mcu_sdk:[11,12,13],bldevcub:14,ble:[1,20],boot2:21,bouffalo:14,cdk:12,ck:16,client:20,cmake:[11,15],cube:14,dac:3,debugg:16,dev:14,device_clos:[0,4,7,8,9,10],device_control:[0,4,7,8,9,10],device_find:9,device_open:[0,4,6,7,8,9,10],device_read:[0,8,9,10],device_regist:9,device_set_callback:[0,4,7,8,9,10],device_unregist:9,device_writ:[8,9,10],dma:[4,27,28],dma_channel_check_busi:4,dma_channel_start:4,dma_channel_stop:4,dma_channel_upd:4,dma_regist:4,dma_reload:4,eclips:13,exampl:15,fatf:22,gcc:15,gpio:[5,29,30,31],gpio_attach_irq:5,gpio_irq_en:5,gpio_read:5,gpio_set_mod:5,gpio_toggl:5,gpio_writ:5,hello:[11,12,13],i2c:[6,32,33],i2c_regist:6,i2c_transf:6,iap:21,jlink:14,keil:12,lab:14,lcd:40,ld:15,link:16,linux:11,lowpow:23,make:11,mcu:19,mdk:12,mtimer:[34,35],openocd:14,option:15,or:11,peripheral_clock_get:2,plu:16,pwm:[7,36,37,38],pwm_channel_start:7,pwm_channel_stop:7,pwm_channel_upd:7,pwm_it_pulse_count_upd:7,pwm_regist:7,ram:27,risc:11,rv:16,sdk:19,server:20,shell:24,sipe:16,spi:[8,39,40],spi_rec:8,spi_regist:8,spi_transmit:8,spi_transmit_rec:8,system_clock_get:2,tft:40,uart:[10,14,41,42],uart_regist:10,window:[12,13],world:[11,12,13],wsl:11,xshell:23}}) \ No newline at end of file diff --git a/docs/development_guide/source/api_reference/api_adc.rst b/docs/development_guide/source/api_reference/api_adc.rst index b97eba7b..b18f24ac 100644 --- a/docs/development_guide/source/api_reference/api_adc.rst +++ b/docs/development_guide/source/api_reference/api_adc.rst @@ -3,13 +3,238 @@ ADC 设备 简介 ------------------------ +ADC (Analog-to-digital Converter) 是用于将模拟形式的连续信号转换为数字形式的离散信号的一类设备,他可以将外围电路传感器产生的模拟信号转化为机器可识别的数字信号。 +博流系列MCU中的ADC设备具有以下特性 + +- 可以选择 12/14/16 bits转换结果输出 +- ADC最大工作时钟为2MHZ +- 支持2.0V,3.2V可选内部参考电压 +- 支持DMA将转换结果搬运到内存 +- 支持单次单通道转换、连续单通道转换、单次多通道转换和连续多通道转换模式四种模式 +- 支持单端与差分两种输入模式 +- 12路外部模拟通道 +- 2路DAC内部通道 +- 1路VBAT/2通道 ADC 设备结构体定义 ------------------------ +.. code-block:: C + + typedef struct adc_device { + struct device parent; + adc_clk_div_t clk_div; + adc_vref_t vref; + bool continuous_conv_mode; + bool differential_mode; + adc_data_width_t data_width; + adc_fifo_threshold_t fifo_threshold; + adc_pga_gain_t gain; + } adc_device_t; + +- parent 继承父类属性 +- clk_div ADC模块时钟内部分频 +- vref 参考电压选择 2.0/3.2V可选 +- continuous_conv_mode 是否选择为连续模式,若为连续模式,则一次adc_start操作,ADC连续工作,直到adc_stop。否则,每adc_start一次,adc仅转换一次结果。 +- differential_mode 选择是否为差分模式,若为差分模式,则可以测量负电压。 +- data_width 测量宽度选择,ADC实际精度为12bits,但是通过OSR多次取平均可以达到14bits/16bits的精度,注意,当选择更高的数据宽度后,频率会因为取平均而下降。详情可参考枚举信息。 +- fifo_threshold 此参数影响DMA搬运阈值以及ADC FIFO中断阈值 +- gain ADC对输入信号的增益选择 +- 其他待补充 ADC 设备参数配置表 ------------------------ +每一个 ADC 设备都有一个参数配置宏,宏定义位于 ``bsp/board/xxx`` 目录下 ``peripheral_config.h`` 文件,变量定义位于 ``hal_adc.c`` 中,因此无需用户自己定义变量。当用户打开对应设备的宏,该设备的配置才生效。例如打开宏 ``BSP_USING_ADC0`` 即生效,同时 ``ADC`` 设备就可以进行注册和使用了。 + +.. code-block:: C + + /*参数配置宏*/ + #if defined(BSP_USING_ADC0) + #ifndef ADC0_CONFIG + #define ADC0_CONFIG \ + { \ + .clk_div = ADC_CLOCK_DIV_32, \ + .vref = ADC_VREF_3P2V, \ + .continuous_conv_mode = DISABLE, \ + .differential_mode = DISABLE, \ + .data_width = ADC_DATA_WIDTH_16B_WITH_256_AVERAGE, \ + .fifo_threshold = ADC_FIFO_THRESHOLD_1BYTE, \ + .gain = ADC_GAIN_1 \ + } + #endif + #endif + + /*变量定义*/ + static adc_device_t adcx_device[ADC_MAX_INDEX] = { + #ifdef BSP_USING_ADC0 + ADC0_CONFIG, + #endif + }; + +.. note:: 上述配置可以通过 ``ADC_DEV(dev)->xxx`` 进行修改,只能在调用 ``device_open`` 之前使用。 + ADC 设备接口 ------------------------ +ADC 设备接口全部遵循标准设备驱动管理层提供的接口。 + + +**ADC_register** +^^^^^^^^^^^^^^^^^^^^^^^^ + +``adc_register`` 用来注册一个 ADC 设备,在注册之前需要打开对应 ADC 设备的宏定义。例如定义宏 ``BSP_USING_ADC0`` 方可使用 ``ADC0`` 设备,注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 ``ADC0`` 设备。 + +.. code-block:: C + + int ADC_register(enum ADC_index_type index, const char *name, uint16_t flag); + +- index 要注册的设备索引 +- name 为注册的设备命名 +- flag 默认可读可写属性 + +``index`` 用来选择 ADC 设备配置,一个 index 对应一个 ADC 设备配置,比如 ``ADC0_INDEX`` 对应 ``ADC0_CONFIG`` 配置,``index`` 有如下可选类型 + +.. code-block:: C + + enum ADC_index_type + { + #ifdef BSP_USING_ADC0 + ADC0_INDEX, + #endif + ADC_MAX_INDEX + }; + +**device_open** +^^^^^^^^^^^^^^^^ + +``device_open`` 用于 ADC 设备的打开,``oflag`` 表示以何种方式打开。 + +.. code-block:: C + + int device_open(struct device *dev, uint16_t oflag); + +- dev 设备句柄 +- oflag 设备的打开方式 +- return 错误码,0 表示打开成功,其他表示错误 + +``oflag`` 可以写入以下参数: + +.. code-block:: C + + #define DEVICE_OFLAG_STREAM_TX 0x001 /* 设备以轮训发送模式打开 */ + #define DEVICE_OFLAG_STREAM_RX 0x002 /* 设备以轮训接收模式打开 */ + #define DEVICE_OFLAG_INT_TX 0x004 /* 设备以中断发送模式打开 */ + #define DEVICE_OFLAG_INT_RX 0x008 /* 设备以中断接收模式打开 */ + #define DEVICE_OFLAG_DMA_TX 0x010 /* 设备以 DMA 发送模式打开 */ + #define DEVICE_OFLAG_DMA_RX 0x020 /* 设备以 DMA 接收模式打开 */ + +**device_close** +^^^^^^^^^^^^^^^^ + +``device_close`` 用于设备的关闭。 + +.. code-block:: C + + int device_close(struct device *dev); + +- dev 设备句柄 +- return 错误码,0 表示关闭成功,其他表示错误 + +**device_control** +^^^^^^^^^^^^^^^^^^^ + +``device_control`` 用于根据命令对 ADC 设备进行控制和参数的修改。 + +.. code-block:: C + + int device_control(struct device *dev, int cmd, void *args); + +- dev 设备句柄 +- cmd 设备控制命令 +- args 控制参数 +- return 不同的控制命令返回的意义不同。 + +串口设备除了标准的控制命令,还具有自己特殊的控制命令。 + +.. code-block:: C + + #define DEVICE_CTRL_ADC_CHANNEL_START 0x10 + #define DEVICE_CTRL_ADC_CHANNEL_STOP 0x11 + #define DEVICE_CTRL_ADC_CHANNEL_CONFIG 0x12 + #define DEVICE_CTRL_ADC_VBAT_ON 0x13 + #define DEVICE_CTRL_ADC_VBAT_OFF 0x14 + #define DEVICE_CTRL_ADC_TSEN_ON 0x15 + #define DEVICE_CTRL_ADC_TSEN_OFF 0x16 + +``args`` 根据不同的 ``cmd`` 传入不同,具体如下: + + ++-----------------------------------+-----------------------+-------------------------------------+ +|cmd |args |description | ++===================================+=======================+=====================================+ +|DEVICE_CTRL_SET_INT |ADC_it_type |开启ADC设备中断 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_CLR_INT |ADC_it_type |关闭ADC设备中断 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_CONFIG |ADC_param_cfg_t* |修改ADC配置 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_CHANNEL_CONFIG |adc_channel_cfg_t* |配置ADC通道信息 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ATTACH_RX_DMA |struct device* |链接接收dma设备 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_CHANNEL_START |struct device* |开始/继续 ADC转换 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_CHANNEL_STOP |NULL |停止ADC转换 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_VBAT_ON |NULL |打开内部VDD测量电路 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_VBAT_OFF |NULL |关闭内部VDD测量电路 | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_TSEN_ON |NULL |打开内部温度测量电路(需硬件支持) | ++-----------------------------------+-----------------------+-------------------------------------+ +|DEVICE_CTRL_ADC_TSEN_OFF |uint32_t* |关闭内部温度测量电路(需硬件支持) | ++-----------------------------------+-----------------------+-------------------------------------+ + + +**device_read** +^^^^^^^^^^^^^^^^ + +``device_read`` 用于 ADC 设备数据的接收,接收方式根据打开方式可以是轮询、中断、dma。 + +.. code-block:: C + + int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); + +- dev 设备句柄 +- pos 无作用 +- buffer 要读入的 buffer 缓冲区 +- size 要读入的长度 +- return 错误码,0 表示读入成功,其他表示错误 + +**device_set_callback** +^^^^^^^^^^^^^^^^^^^^^^^^ + +``device_set_callback`` 用于注册一个ADC阈值中断回调函数。 + +.. code-block:: C + + int device_set_callback(struct device *dev, void (*callback)(struct device *dev, void *args, uint32_t size, uint32_t event)); + +- dev 设备句柄 +- callback 要注册的中断回调函数 + + - dev 设备句柄 + - args 接收发送缓冲区,数据类型为 uint8_t* + - size 传输长度 + - event 中断事件类型 + +串口设备 ``event`` 类型如下 + +.. code-block:: C + + enum ADC_event_type + { + ADC_EVENT_FIFO_READY, + ADC_EVENT_OVERRUN, + ADC_EVENT_UNDERRUN, + }; \ No newline at end of file diff --git a/docs/development_guide/source/api_reference/api_ble.rst b/docs/development_guide/source/api_reference/api_ble.rst new file mode 100644 index 00000000..12f6a5c4 --- /dev/null +++ b/docs/development_guide/source/api_reference/api_ble.rst @@ -0,0 +1,709 @@ +.. _ble-index: + +BLE +================== + +概述 +------ +- BLE支持的特性: + + 蓝牙HOST特性 + - GAP支持的角色:Peripheral与Central,Observer与Broadcaster + - GATT支持的角色:Server与Client + - 支持配对包括蓝牙4.2中的安全连接特性 + - 支持永久存储蓝牙特定的设置和数据 + + 蓝牙mesh特性 + - 支持Relay, Friend Node, Low-Power Node (LPN) and GATT Proxy角色 + - 支持两种Provisioning bearers(PB-ADV & PB-GATT) +- BLE协议栈的架构: + .. figure:: img/image1.png + + + 总共有3个主要层,共同构成了一个完整的蓝牙低能耗协议栈 + - Host:这一层位于应用程序之下,由多个(非实时)网络和传输协议组成,使应用程序能够以标准和互操作的方式与对等设备通信。 + - Controller:控制器实现了链路层(LE LL),这是一种低层次的实时协议,它与无线电硬件一起提供了空中通信的标准互操作。LL处理包的接收和传输,保证数据的传递,并处理所有LL控制程序。 + - Radio Hardware:实现所需的模拟和数字基带功能块,允许链路层固件在频谱的2.4GHz波段发送和接收。 + +- 主控Host: + .. figure:: img/image2.png + + * 蓝牙Host层实现了所有高级协议和配置文件,最重要的是它为应用程序提供了高级API + - HCI:Host与controller接口 + - L2CAP:逻辑链路控制和适应协议 + - GATT:通用属性配置层(Generic Attribute Profile) + - GAP:通用访问配置层(Generic Access Profile) + - SMP:安全管理器配置层(Security Manager Specification) + +- 应用Application + * 应用层是用户开发实际蓝牙应用的地方,包含必要的协议栈参数设置,以及各种功能函数的调用。我们分别从蓝牙从机和蓝牙主机两种设备来分析。 + * 蓝牙从机 + - 相关硬件和基础服务初始化 + - 设置广播参数:广播数据,广播间隔,扫描回应等参数或者数据 + - 设置Profile:添加从机服务、特征值,还有设置回调函数用于接收主机数据等 + - 设置配对参数(可选) + - 启动广播,开始运行 + - 等待相关事件,及事件处理,例如收到主机发来的数据,被链接等等 + * 蓝牙主机 + - 相关硬件和基础服务初始化 + - 设置扫描参数 + - 设置连接参数 + - 设置配对参数(可选) + - 启动协议栈,开始运行 + - 等待相关事件,及事件处理,例如扫描事件,从机的Notify事件等等。 + +API参考 +---------- + +- API介绍 + +``void ble_controller_init(uint8_t task_priority)`` + +:: + + /** + * function controller层初始化 + * @param[in] task_priority: 任务优先级 + * @return 空 + */ + +``int hci_driver_init(void)`` + +:: + + /** + * function HCI接口驱动初始化 + * @param[in] 空 + * @return 0:成功,!=0:失败 + */ + +``int bt_enable(bt_ready_cb_t cb)`` + +:: + + /** + * function Ble使能 + * @param[in] cb:如果成功调用回调函数 + * @return 0:成功,!=0:失败 + */ + +``int bt_le_adv_start(const struct bt_le_adv_param *param,const struct bt_data *ad, size_t ad_len,`` + ``const struct bt_data *sd, size_t sd_len)`` + +:: + + /** + * function 开启BLE广播 + * + * @param[in] param: 指向广播配置参数指针 + * @param[in] ad: 指向广播包中数据指针 + * @param[in] ad_len: 广播包中数据的长度 + * @param[in] sd: 指向扫描响应包数据指针 + * @param[in] sd_len: 扫描响应包数据的长度 + * @return 0:成功,!=0:失败 + */ + + +``int bt_le_adv_update_data(const struct bt_data *ad, size_t ad_len,const struct bt_data *sd, size_t sd_len)`` + + +:: + + /** + * function 更新BLE广播数据 + * @param[in] ad: 指向广播包中数据指针 + * @param[in] ad_len: 广播包中数据的长度 + * @param[in] sd: 指向扫描响应包数据指针 + * @param[in] sd_len: 扫描响应包数据的长度 + * @return 0:成功,!=0:失败 + */ + +``int bt_le_adv_stop(void)`` + + +:: + + /** + * function 停止BLE广播 + * @param[in] 空 + * @return 0:成功,!=0:失败 + */ + + +``int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb)`` + +:: + + /** + * function 开启BLE扫描 + * @param[in] param: 指向扫描参数的指针 + * @param[in] cb: 扫描回调函数 + * @return 0:成功,!=0:失败 + */ + +``int bt_le_scan_stop(void)`` + +:: + + /** + * function 停止BLE扫描 + * @param[in] 空 + * @return 0:成功,!=0:失败 + */ + +``int bt_le_whitelist_add(const bt_addr_le_t *addr)`` + +:: + + /** + * function 通过地址添加设备到白名单列表中 + * @param[in] addr:指向需要添加设备地址的指针 + * @return 0:成功,!=0:失败 + */ + +``int bt_le_whitelist_rem(const bt_addr_le_t *addr)`` + +:: + + + /** + * function 从白名单列表中移除设备 + * @param[in] addr:指向需要移除设备地址的指针 + * @return 0:成功,!=0:失败 + */ + +``int bt_le_whitelist_clear(void)`` + + +:: + + /** + * function 清除白名单列表 + * @param[in] 空 + * @return 0:成功,!=0:失败 + */ + +``int bt_le_set_chan_map(u8_t chan_map[5])`` + +:: + + /** + * function 设置(LE)通道映射 + * @param[in] chan_map:通道数组 + * @return 0:成功,!=0:失败 + */ + +``int bt_unpair(u8_t id, const bt_addr_le_t *addr)`` + +:: + + /** + * function 清除配对信息 + * @param[in] id: 本地标识(大多只是默认的BT ID) + * @param[in] addr: 远端设备地址,NULL或者BT_ADDR_LE_ANY清除所有远端设备 + * @return 0:成功,!=0:失败 + */ + +``int bt_conn_get_info(const struct bt_conn *conn, struct bt_conn_info *info)`` + +:: + + /** + * function 获取当前连接设备的信息 + * @param[in] conn: 指向当前连接的指针 + * @param[in] info: 指向当前连接设备信息的指针 + * @return 0:成功,!=0:失败 + */ + + +``int bt_conn_get_remote_dev_info(struct bt_conn_info *info)`` + +:: + + /** + * function 获取已连接设备的信息 + * @param[in] info: 指向当前连接设备信息的指针 + * @return 已连接设备的个数 + */ + +``int bt_conn_le_param_update(struct bt_conn *conn,const struct bt_le_conn_param *param)`` + +:: + + /** + * function 更新连接参数 + * @param[in] conn: 指向当前连接的指针 + * @param[in] param: 指向连接参数的指针 + * @return 0:成功,!=0:失败 + */ + +``int bt_conn_disconnect(struct bt_conn *conn, u8_t reason)`` + +:: + + /** + * function 断开当前连接 + * @param[in] conn: 指向当前连接的指针 + * @param[in] reason:断开当前连接的原因 + * @return 0:成功,!=0:失败 + */ + +``struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,const struct bt_le_conn_param *param)`` + +:: + + /** + * function 创建连接 + * @param[in] peer: 需要连接设备地址的指针 + * @param[in] param: 指向连接参数指针 + * @return 成功:有效的连接对象,否则失败 + */ + + +``int bt_conn_create_auto_le(const struct bt_le_conn_param *param)`` + +:: + + /** + * function 自动创建连接白名单列表中的设备 + * @param[in] param: 指向连接参数指针 + * @return 0:成功,!=0:失败 + */ + +``int bt_conn_create_auto_stop(void)`` + +:: + + /** + * function 停止自动创建连接白名单列表中的设备 + * @param[in] 空 + * @return 0:成功,!=0:失败 + */ + +``int bt_le_set_auto_conn(const bt_addr_le_t *addr,const struct bt_le_conn_param *param)`` + +:: + + /** + * function 自动创建连接远端设备 + * @param[in] addr: 远端设备地址指针 + * @param[in] param: 指向连接参数指针 + * @return 0:成功,!=0:失败 + */ + +``struct bt_conn *bt_conn_create_slave_le(const bt_addr_le_t *peer,const struct bt_le_adv_param *param)`` + +:: + + /** + * function 发起定向的广播包给远端设备 + * @param[in] peer: 远端设备地址指针 + * @param[in] param: 指向广播参数的指针 + * @return 成功:有效的连接对象,否则失败 + */ + +``int bt_conn_set_security(struct bt_conn *conn, bt_security_t sec)`` + +:: + + /** + * function 设置连接安全等级 + * @param[in] conn: 指向连接对象的指针 + * @param[in] sec: 安全等级 + * @return 0:成功,!=0:失败 + */ + +``bt_security_t bt_conn_get_security(struct bt_conn *conn)`` + +:: + + /** + * function 获取当前连接的安全等级 + * @param[in] conn: 指向连接对象的指针 + * @return 安全级别 + */ + + +``u8_t bt_conn_enc_key_size(struct bt_conn *conn)`` + +:: + + /** + * function 获取当前连接的加密key的大小 + * @param[in] conn: 指向连接对象的指针 + * @return 加密key的大小 + */ + + +``void bt_conn_cb_register(struct bt_conn_cb *cb)`` + +:: + + /** + * function 注册连接回调函数 + * @param[in] cb: 连接回调函数 + * @return 空 + */ + +``void bt_set_bondable(bool enable)`` + +:: + + /** + * function 设置/清除SMP配对请求/响应数据认证需求中的绑定标志 + * @param[in] enable: 1,使能,0:不使能 + * @return 空 + */ + +``int bt_conn_auth_cb_register(const struct bt_conn_auth_cb *cb)`` + +:: + + /** + * function 注册认证回调函数 + * @param[in] cb: 回调函数指针 + * @return 0:成功,!=0:失败 + */ + +``int bt_conn_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey)`` + +:: + + /** + * function 用密钥回复对方 + * @param[in] conn: 连接对象指针 + * @param[in] passkey: 输入的密钥 + * @return 0:成功,!=0:失败 + */ + +``int bt_conn_auth_cancel(struct bt_conn *conn)`` + +:: + + /** + * function 取消认证过程 + * @param[in] conn: 连接对象指针 + * @return 0:成功,!=0:失败 + */ + +``int bt_conn_auth_passkey_confirm(struct bt_conn *conn)`` + +:: + + /** + * function 如果密码匹配,回复对方 + * @param[in] conn: 连接对象的指针 + * @return 0:成功,!=0:失败 + */ + +``int bt_conn_auth_pincode_entry(struct bt_conn *conn, const char *pin)`` + +:: + + /** + * function 用PIN码进行回复对方 + * @param[in] conn: 连接对象的指针 + * @param[in] pin: PIN码的指针 + * @return 0:成功,!=0:失败 + */ + +``int bt_le_read_rssi(u16_t handle,int8_t *rssi)`` + +:: + + /** + * function 读取对方RSSI值 + * @param[in] handle:连接的句柄值 + * @param[in] rssi: rssi的指针 + * @return 0:成功,!=0:失败 + */ + +``int bt_get_local_address(bt_addr_le_t *adv_addr)`` + +:: + + /** + * function 读取本机的地址 + * @param[in] adv_addr: 指向地址的指针 + * @return 0:成功,!=0:失败 + */ + +``int bt_set_tx_pwr(int8_t power)`` + +:: + + /** + * function 设置本机发射功率 + * @param[in] power: 功率值 + * @return 0:成功,!=0:失败 + */ + +数据结构参考 +--------------- + +``bt_le_adv_param``\ 数据结构: + +.. code:: c + + /** LE Advertising Parameters. */ + struct bt_le_adv_param { + /** Local identity */ + u8_t id; + + /** Bit-field of advertising options */ + u8_t options; + + /** Minimum Advertising Interval (N * 0.625) */ + u16_t interval_min; + + /** Maximum Advertising Interval (N * 0.625) */ + u16_t interval_max; + + #if defined(CONFIG_BT_STACK_PTS) + u8_t addr_type; + #endif + }; + +此数据结构用来配置广播参数,包括本地识别id、广播选项位域、广播间隙等,其中广播选项位域有如下枚举类型参数可选: + +.. code:: c + + enum { + /** Convenience value when no options are specified. */ + BT_LE_ADV_OPT_NONE = 0, + + /** Advertise as connectable. Type of advertising is determined by + * providing SCAN_RSP data and/or enabling local privacy support. + */ + BT_LE_ADV_OPT_CONNECTABLE = BIT(0), + + /** Don't try to resume connectable advertising after a connection. + * This option is only meaningful when used together with + * BT_LE_ADV_OPT_CONNECTABLE. If set the advertising will be stopped + * when bt_le_adv_stop() is called or when an incoming (slave) + * connection happens. If this option is not set the stack will + * take care of keeping advertising enabled even as connections + * occur. + */ + BT_LE_ADV_OPT_ONE_TIME = BIT(1), + + /** Advertise using the identity address as the own address. + * @warning This will compromise the privacy of the device, so care + * must be taken when using this option. + */ + BT_LE_ADV_OPT_USE_IDENTITY = BIT(2), + + /** Advertise using GAP device name */ + BT_LE_ADV_OPT_USE_NAME = BIT(3), + + /** Use low duty directed advertising mode, otherwise high duty mode + * will be used. This option is only effective when used with + * bt_conn_create_slave_le(). + */ + BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY = BIT(4), + + /** Enable use of Resolvable Private Address (RPA) as the target address + * in directed advertisements when CONFIG_BT_PRIVACY is not enabled. + * This is required if the remote device is privacy-enabled and + * supports address resolution of the target address in directed + * advertisement. + * It is the responsibility of the application to check that the remote + * device supports address resolution of directed advertisements by + * reading its Central Address Resolution characteristic. + */ + BT_LE_ADV_OPT_DIR_ADDR_RPA = BIT(5), + + /** Use whitelist to filter devices that can request scan response + * data. + */ + BT_LE_ADV_OPT_FILTER_SCAN_REQ = BIT(6), + + /** Use whitelist to filter devices that can connect. */ + BT_LE_ADV_OPT_FILTER_CONN = BIT(7), + }; + +如果需要发送一个广播包,配置可以如下: + +.. code:: c + + param.id = 0; + param.options = (BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_USE_NAME | BT_LE_ADV_OPT_ONE_TIME); + param.interval_min = 0x00a0; + param.interval_max = 0x00f0; + +``bt_data``\ 数据结构: + +.. code:: c + + struct bt_data { + u8_t type; + u8_t data_len; + const u8_t *data; + }; + +此数据结构用来填充广播包中的数据,具体的数据包类型可以参考如下: + +.. code:: c + + Service UUID + Local Name + Flags + Manufacturer Specific Data + TX Power Level + Secure Simple Pairing OOB + Security Manager OOB + Security Manager TK Value + Slave Connection Interval Range + Service Solicitation + Service Data + Appearance + Public Target Address + Random Target Address + Advertising Interval + LE Bluetooth Device Address + LE Role + Uniform Resource Identifier + LE Supported Features + Channel Map Update Indication + +用该数据结构配置一个广播包数据,如下所示: + +.. code:: c + + struct bt_data ad_discov[] = { + BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), + BT_DATA(BT_DATA_NAME_COMPLETE, "BL602-BLE-DEV", 13), + }; + +``bt_le_scan_param``\ 数据结构: + +.. code:: c + + /** LE scan parameters */ + struct bt_le_scan_param { + /** Scan type (BT_LE_SCAN_TYPE_ACTIVE or BT_LE_SCAN_TYPE_PASSIVE) */ + u8_t type; + + /** Bit-field of scanning filter options. */ + u8_t filter_dup; + + /** Scan interval (N * 0.625 ms) */ + u16_t interval; + + /** Scan window (N * 0.625 ms) */ + u16_t window; + }; + +此数据结构用来填充扫描参数, +type:为扫描类型有2种类型BT_LE_SCAN_TYPE_ACTIVE(0x01)、BT_LE_SCAN_TYPE_PASSIVE(0x00)。 +filter_dup:0x00,除定向广告外,接受所有广播和扫描响应,0x01,只接收白名单列表中设备的广播和扫描响应。 +interval:扫描间隙。 +window:扫描窗口。 + +如果开启扫描请求,可以配置如下: + +.. code:: c + + scan_param.type = BT_LE_SCAN_TYPE_PASSIVE + scan_param.filter_dup = 0x00 + interval=BT_GAP_SCAN_SLOW_INTERVAL_1 + window=BT_GAP_SCAN_SLOW_WINDOW_1 + + +``bt_le_conn_param``\ 数据结构: + +.. code:: c + + /** Connection parameters for LE connections */ + struct bt_le_conn_param { + u16_t interval_min; + u16_t interval_max; + u16_t latency; + u16_t timeout; + + #if defined(CONFIG_BT_STACK_PTS) + u8_t own_address_type; + #endif + }; + +此数据结构用来填充连接参数,interval_min:连接间隙最少值(0x0018),interval_max:连接间隙最大值(0x0028), +latency:指定为连接事件数的连接允许的最大从延迟。 +timeout:连接超时时间。 + +配置该数据结构,如下: + +.. code:: c + + interval_min=BT_GAP_INIT_CONN_INT_MIN(0x0018) + interval_max=BT_GAP_INIT_CONN_INT_MAX(0x0028) + latency=0 + timeout=400 + +``bt_conn``\ 数据结构: + +.. code:: c + + struct bt_conn { + u16_t handle; + u8_t type; + u8_t role; + + ATOMIC_DEFINE(flags, BT_CONN_NUM_FLAGS); + + /* Which local identity address this connection uses */ + u8_t id; + + #if defined(CONFIG_BT_SMP) || defined(CONFIG_BT_BREDR) + bt_security_t sec_level; + bt_security_t required_sec_level; + u8_t encrypt; + #endif /* CONFIG_BT_SMP || CONFIG_BT_BREDR */ + + /* Connection error or reason for disconnect */ + u8_t err; + + bt_conn_state_t state; + + u16_t rx_len; + struct net_buf *rx; + + /* Sent but not acknowledged TX packets with a callback */ + sys_slist_t tx_pending; + /* Sent but not acknowledged TX packets without a callback before + * the next packet (if any) in tx_pending. + */ + u32_t pending_no_cb; + + /* Completed TX for which we need to call the callback */ + sys_slist_t tx_complete; + struct k_work tx_complete_work; + + + /* Queue for outgoing ACL data */ + struct k_fifo tx_queue; + + /* Active L2CAP channels */ + sys_slist_t channels; + + atomic_t ref; + + /* Delayed work for connection update and other deferred tasks */ + struct k_delayed_work update_work; + + union { + struct bt_conn_le le; + #if defined(CONFIG_BT_BREDR) + struct bt_conn_br br; + struct bt_conn_sco sco; + #endif + }; + + #if defined(CONFIG_BT_REMOTE_VERSION) + struct bt_conn_rv { + u8_t version; + u16_t manufacturer; + u16_t subversion; + } rv; + #endif + }; + +此数据结构为当前连接数据结构,其中包括BLE蓝牙连接相关的参数,连接成功后该数据结构可以被用户调用。 + + diff --git a/docs/development_guide/source/api_reference/api_clock.rst b/docs/development_guide/source/api_reference/api_clock.rst index c6958a71..da42102c 100644 --- a/docs/development_guide/source/api_reference/api_clock.rst +++ b/docs/development_guide/source/api_reference/api_clock.rst @@ -46,9 +46,9 @@ - type 获取的外设时钟频率类型 ``type`` 提供以下几种类型 - + .. code-block:: C - + enum peripheral_clock_type { PERIPHERAL_CLOCK_UART = 0, diff --git a/docs/development_guide/source/api_reference/api_dma.rst b/docs/development_guide/source/api_reference/api_dma.rst index d4306519..182c791b 100644 --- a/docs/development_guide/source/api_reference/api_dma.rst +++ b/docs/development_guide/source/api_reference/api_dma.rst @@ -29,7 +29,7 @@ DMA 设备结构体定义 uint8_t dst_burst_size; uint8_t src_width; uint8_t dst_width; - dma_lli_ctrl_t *lli_cfg; + dma_lli_ctrl_t *lli_cfg; } dma_device_t; - parent 继承父类属性 @@ -60,7 +60,7 @@ DMA 设备结构体定义 .. code-block:: C - #define DMA_LLI_ONCE_MODE 0 + #define DMA_LLI_ONCE_MODE 0 #define DMA_LLI_CYCLE_MODE 1 ``src_req`` 提供以下类型 @@ -76,8 +76,8 @@ DMA 设备结构体定义 #define DMA_REQUEST_I2C0_TX 0x00000007 /*!< DMA request peripheral:I2C TX */ #define DMA_REQUEST_SPI0_RX 0x0000000A /*!< DMA request peripheral:SPI RX */ #define DMA_REQUEST_SPI0_TX 0x0000000B /*!< DMA request peripheral:SPI TX */ - #define DMA_REQUEST_I2S_RX 0x00000014 /*!< DMA request peripheral:I2S RX */ - #define DMA_REQUEST_I2S_TX 0x00000015 /*!< DMA request peripheral:I2S TX */ + #define DMA_REQUEST_I2S_RX 0x00000014 /*!< DMA request peripheral:I2S RX */ + #define DMA_REQUEST_I2S_TX 0x00000015 /*!< DMA request peripheral:I2S TX */ #define DMA_REQUEST_ADC0 0x00000016 /*!< DMA request peripheral:ADC0 */ #define DMA_REQUEST_DAC0 0x00000017 /*!< DMA request peripheral:DAC0 */ #define DMA_REQUEST_USB_EP0 0x00000018 /*!< DMA request peripheral:USB EP0*/ @@ -102,8 +102,8 @@ DMA 设备结构体定义 #define DMA_REQUEST_I2C0_TX 0x00000007 /*!< DMA request peripheral:I2C TX */ #define DMA_REQUEST_SPI0_RX 0x0000000A /*!< DMA request peripheral:SPI RX */ #define DMA_REQUEST_SPI0_TX 0x0000000B /*!< DMA request peripheral:SPI TX */ - #define DMA_REQUEST_I2S_RX 0x00000014 /*!< DMA request peripheral:I2S RX */ - #define DMA_REQUEST_I2S_TX 0x00000015 /*!< DMA request peripheral:I2S TX */ + #define DMA_REQUEST_I2S_RX 0x00000014 /*!< DMA request peripheral:I2S RX */ + #define DMA_REQUEST_I2S_TX 0x00000015 /*!< DMA request peripheral:I2S TX */ #define DMA_REQUEST_ADC0 0x00000016 /*!< DMA request peripheral:ADC0 */ #define DMA_REQUEST_DAC0 0x00000017 /*!< DMA request peripheral:DAC0 */ #define DMA_REQUEST_USB_EP0 0x00000018 /*!< DMA request peripheral:USB EP0*/ @@ -172,7 +172,7 @@ DMA 设备参数配置表 } #endif #endif - + /*变量定义*/ static dma_device_t dmax_device[DMA_MAX_INDEX] = @@ -212,11 +212,11 @@ DMA 设备接口全部遵循标准设备驱动管理层提供的接口。并且 **dma_register** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``dma_register`` 用来注册一个 DMA 设备的一个通道,在注册之前需要打开对应 DMA 设备的通道宏定义。例如定义宏 ``BSP_USING_DMA_CH0`` 方可使用 ``DMA`` 设备的 0 通道,注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 ``DMA`` 设备的 0 通道。 .. code-block:: C - + int dma_register(enum dma_index_type index, const char *name, uint16_t flag); - index 要注册的设备索引 @@ -226,7 +226,7 @@ DMA 设备接口全部遵循标准设备驱动管理层提供的接口。并且 ``index`` 用来选择 DMA 设备某个通道的配置,一个 index 对应一个 DMA 设备的一个通道配置,比如 ``DMA_CH0_INDEX`` 对应 DMA 通道0 配置,``index`` 有如下可选类型 .. code-block:: C - + enum dma_index_type { #ifdef BSP_USING_DMA0_CH0 @@ -263,7 +263,7 @@ DMA 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -287,11 +287,11 @@ DMA 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_close(struct device *dev); + int device_close(struct device *dev); - dev 设备句柄 - return 错误码,0 表示关闭成功,其他表示错误 - + **device_control** ^^^^^^^^^^^^^^^^^^^ @@ -299,7 +299,7 @@ DMA 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_control(struct device *dev, int cmd, void *args); + int device_control(struct device *dev, int cmd, void *args); - dev 设备句柄 - cmd 设备控制命令 @@ -348,7 +348,7 @@ DMA 设备除了标准的控制命令,还具有自己特殊的控制命令。 - dev 设备句柄 - args 无用 - size 无用 - - event 中断事件类型 + - event 中断事件类型 DMA 设备 ``event`` 类型如下 diff --git a/docs/development_guide/source/api_reference/api_gpio.rst b/docs/development_guide/source/api_reference/api_gpio.rst index 2ccd7d19..95737f9e 100644 --- a/docs/development_guide/source/api_reference/api_gpio.rst +++ b/docs/development_guide/source/api_reference/api_gpio.rst @@ -27,7 +27,7 @@ GPIO 设备接口 ``gpio_set_mode`` 用来配置 gpio 的模式。 .. code-block:: C - + void gpio_set_mode(uint32_t pin, uint32_t mode); - pin 要配置的引脚 @@ -36,7 +36,7 @@ GPIO 设备接口 ``mode`` 提供以下几种类型 .. code-block:: C - + #define GPIO_OUTPUT_MODE 0 #define GPIO_OUTPUT_PP_MODE 1 #define GPIO_OUTPUT_PD_MODE 2 @@ -58,31 +58,31 @@ GPIO 设备接口 ``gpio_write`` 设置引脚电平 .. code-block:: C - + void gpio_write(uint32_t pin, uint32_t value); - pin 要设置的引脚 - value 要设置的电平 - + **gpio_toggle** ^^^^^^^^^^^^^^^^^^^^^^^^ ``gpio_toggle`` 翻转引脚电平 .. code-block:: C - + void gpio_toggle(uint32_t pin); - pin 要翻转的引脚 **gpio_read** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``gpio_read`` 读取引脚电平 .. code-block:: C - + int gpio_read(uint32_t pin); @@ -91,11 +91,11 @@ GPIO 设备接口 **gpio_attach_irq** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``gpio_attach_irq`` 为中断引脚附加中断回调函数 .. code-block:: C - + void gpio_attach_irq(uint32_t pin, void (*cbfun)(uint32_t pin)); - pin 要附加中断回调的引脚 @@ -103,11 +103,11 @@ GPIO 设备接口 **gpio_irq_enable** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``gpio_irq_enable`` 开启gpio某个引脚的中断 .. code-block:: C - + void gpio_irq_enable(uint32_t pin,uint8_t enabled); - pin 要开启或者关闭中断的引脚 diff --git a/docs/development_guide/source/api_reference/api_i2c.rst b/docs/development_guide/source/api_reference/api_i2c.rst index a6dca85e..4f606f87 100644 --- a/docs/development_guide/source/api_reference/api_i2c.rst +++ b/docs/development_guide/source/api_reference/api_i2c.rst @@ -30,7 +30,7 @@ I2C 设备结构体定义 - parent 继承父类属性 - ch i2c id,0 表示 i2c0,1 表示 i2c1 - mode i2c 传输模式,0 为使用硬件 i2c,1 为使用软件 i2c,当前软件 i2c 暂时无效 -- phase +- phase - 其他待补充 I2C 设备参数配置表 @@ -70,11 +70,11 @@ I2C 设备标准接口当前仅使用 ``device_open`` , 并提供标准的数据 **i2c_register** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``i2c_register`` 用来注册一个 I2C 设备,在注册之前需要打开对应 I2C 设备的宏定义。例如定义宏 ``BSP_USING_I2C0`` 方可使用 ``I2C0`` 设备,注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 ``I2C0`` 设备。 .. code-block:: C - + int i2c_register(enum i2c_index_type index, const char *name, uint16_t flag); - index 要注册的设备索引 @@ -84,7 +84,7 @@ I2C 设备标准接口当前仅使用 ``device_open`` , 并提供标准的数据 ``index`` 用来选择 I2C 设备,一个 index 对应一个 I2C 设备配置,比如 ``I2C0_INDEX`` 对应 ``I2C0_CONFIG`` 配置,``index`` 有如下可选类型 .. code-block:: C - + enum i2c_index_type { #ifdef BSP_USING_I2C0 @@ -100,7 +100,7 @@ I2C 设备标准接口当前仅使用 ``device_open`` , 并提供标准的数据 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -124,7 +124,7 @@ I2C 设备标准接口当前仅使用 ``device_open`` , 并提供标准的数据 .. code-block:: C - int i2c_transfer(struct device *dev, i2c_msg_t msgs[], uint32_t num); + int i2c_transfer(struct device *dev, i2c_msg_t msgs[], uint32_t num); - dev 设备句柄 - msgs 需要传输的消息 diff --git a/docs/development_guide/source/api_reference/api_pwm.rst b/docs/development_guide/source/api_reference/api_pwm.rst index b298424f..0c30b6e1 100644 --- a/docs/development_guide/source/api_reference/api_pwm.rst +++ b/docs/development_guide/source/api_reference/api_pwm.rst @@ -6,7 +6,7 @@ PWM 设备 脉冲宽度调制(Pulse width modulation,简称 PWM)是一种用数字方式实现模拟电压控制的技术。它是通过对一系列脉冲的宽度进行调制,等效出所需要的波形(包含形状以及幅值),对模拟信号电平进行数字编码,也就是说通过调节占空比的变化来调节信号、能量等的变化,占空比就是指在一个周期内,信号处于高电平的时间占据整个信号周期的百分比,例如方波的占空比就是50%。博流系列 MCU 中 DMA 设备具有以下特性: -- 支持5通道PWM信号生成 +- 支持5通道 PWM 信号生成 - 三种时钟源可选择(总线时钟 、晶振时钟 、慢速时钟 <32k>),搭配 16-bit 时钟分频器 - 双门限值域设定,增加脉冲弹性 @@ -15,21 +15,29 @@ PWM 设备结构体定义 .. code-block:: C - typedef struct pwm_device - { + typedef struct pwm_device { struct device parent; uint8_t ch; - uint32_t frequency; - uint8_t dutycycle; + uint8_t polarity_invert_mode; + uint16_t period; + uint16_t threshold_low; + uint16_t threshold_high; uint16_t it_pulse_count; + } pwm_device_t; - parent 继承父类属性 - ch 通道号,使能PWM通道0则ch为0,使能PWM通道0则ch为1,以此类推 -- frequency 默认频率 -- dutycycle 默认占空比(0-100) +- polarity_invert_mode 极性翻转使能 +- period PWM 周期值 +- threshold_low PWM 低门限阈值 +- threshold_high PWM 高门限阈值 - it_pulse_count 触发中断条件的周期计数值 +.. note:: PWM 实际频率 = PWM 时钟源/分频/period ,period 非 PWM 实际周期, + +.. note:: PWM 占空比 = threshold_low/threshold_high * 100% + PWM 设备参数配置表 ------------------------ @@ -40,15 +48,19 @@ PWM 设备参数配置表 /*参数配置宏*/ #if defined(BSP_USING_PWM_CH2) #ifndef PWM_CH2_CONFIG - #define PWM_CH2_CONFIG \ - { \ - .ch = 2, \ - .frequency = 1000000, \ - .dutycycle = 0, \ - } + #define PWM_CH2_CONFIG \ + { \ + .ch = 2, \ + .polarity_invert_mode = DISABLE, \ + .period = 0, \ + .threshold_low = 0, \ + .threshold_high = 0, \ + .it_pulse_count = 0, \ + } #endif #endif + /*变量定义*/ static pwm_device_t pwmx_device[PWM_MAX_INDEX] = { #ifdef BSP_USING_PWM_CH0 @@ -77,11 +89,11 @@ PWM 设备接口全部遵循标准设备驱动管理层提供的接口。并且 **pwm_register** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``pwm_register`` 用来注册一个 PWM 设备的一个通道,在注册之前需要打开对应 PWM 设备某个通道的宏定义,例如定义 ``BSP_USING_PWM_CH0`` 方可使用 ``PWM`` 通道0 设备。注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 PWM 设备。 .. code-block:: C - + int pwm_register(enum pwm_index_type index, const char *name, uint16_t flag); - index 要注册的设备索引 @@ -91,7 +103,7 @@ PWM 设备接口全部遵循标准设备驱动管理层提供的接口。并且 ``index`` 用来选择 PWM 设备某个通道的配置,一个 index 对应一个 PWM 设备的一个通道配置,比如 ``PWM_CH0_INDEX`` 对应 PWM 通道0 配置,``index`` 有如下可选类型 .. code-block:: C - + enum pwm_index_type { #ifdef BSP_USING_PWM_CH0 @@ -119,7 +131,7 @@ PWM 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -143,11 +155,11 @@ PWM 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_close(struct device *dev); + int device_close(struct device *dev); - dev 设备句柄 - return 错误码,0 表示关闭成功,其他表示错误 - + **device_control** ^^^^^^^^^^^^^^^^^^^ @@ -155,7 +167,7 @@ PWM 设备接口全部遵循标准设备驱动管理层提供的接口。并且 .. code-block:: C - int device_control(struct device *dev, int cmd, void *args); + int device_control(struct device *dev, int cmd, void *args); - dev 设备句柄 - cmd 设备控制命令 @@ -170,21 +182,23 @@ PWM 设备除了标准的控制命令,还具有自己特殊的控制命令。 ``args`` 根据不同的 ``cmd`` 传入不同,具体如下: -+------------------------------------------+-----------------+----------------------------+ -|cmd |args |description | -+==========================================+=================+============================+ -|DEVICE_CTRL_SET_INT |NULL |开启pwm传输完成中断 | -+------------------------------------------+-----------------+----------------------------+ -|DEVICE_CTRL_CLR_INT |NULL |关闭pwm传输完成中断 | -+------------------------------------------+-----------------+----------------------------+ -|DEVICE_CTRL_RESUME |NULL |恢复pwm通道 | -+------------------------------------------+-----------------+----------------------------+ -|DEVICE_CTRL_SUSPEND |NULL |挂起pwm通道 | -+------------------------------------------+-----------------+----------------------------+ -|DEVICE_CTRL_CONFIG |pwm_config_t |配置pwm通道频率和占空比 | -+------------------------------------------+-----------------+----------------------------+ -|DEIVCE_CTRL_PWM_IT_PULSE_COUNT_CONFIG |uint32_t* |配置中断计数阈值 | -+------------------------------------------+-----------------+----------------------------+ ++------------------------------------------+---------------------------+--------------------------+ +|cmd |args |description | ++==========================================+===========================+==========================+ +|DEVICE_CTRL_SET_INT |NULL |弃用 | ++------------------------------------------+---------------------------+--------------------------+ +|DEVICE_CTRL_CLR_INT |NULL |弃用 | ++------------------------------------------+---------------------------+--------------------------+ +|DEVICE_CTRL_RESUME |NULL |开启当前PWM通道 | ++------------------------------------------+---------------------------+--------------------------+ +|DEVICE_CTRL_SUSPEND |NULL |关闭当前PWM通道 | ++------------------------------------------+---------------------------+--------------------------+ +|DEIVCE_CTRL_PWM_FREQUENCE_CONFIG |uint32_t |配置当前PWM通道周期值 | ++------------------------------------------+---------------------------+--------------------------+ +|DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG |pwm_dutycycle_config_t |配置当前PWM通道占空比 | ++------------------------------------------+---------------------------+--------------------------+ +|DEIVCE_CTRL_PWM_IT_PULSE_COUNT_CONFIG |uint32_t |配置触发PWM中断周期值 | ++------------------------------------------+---------------------------+--------------------------+ **device_set_callback** ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -201,7 +215,7 @@ PWM 设备除了标准的控制命令,还具有自己特殊的控制命令。 - dev 设备句柄 - args 无用 - size 无用 - - event 中断事件类型 + - event 中断事件类型 PWM设备 ``event`` 类型如下 diff --git a/docs/development_guide/source/api_reference/api_spi.rst b/docs/development_guide/source/api_reference/api_spi.rst index d77bd239..0fe82fd3 100644 --- a/docs/development_guide/source/api_reference/api_spi.rst +++ b/docs/development_guide/source/api_reference/api_spi.rst @@ -22,7 +22,7 @@ SPI 设备结构体定义 ------------------------ .. code-block:: C - + typedef struct spi_device { struct device parent; @@ -84,7 +84,7 @@ SPI 设备结构体定义 ``datasize`` 提供以下类型 .. code-block:: C - + #define SPI_DATASIZE_8BIT 0 #define SPI_DATASIZE_16BIT 1 #define SPI_DATASIZE_24BIT 2 @@ -132,11 +132,11 @@ SPI 设备接口全部遵循标准设备驱动管理层提供的接口。 **spi_register** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``spi_register`` 用来注册一个 SPI 设备,在注册之前需要打开对应 SPI 设备的宏定义,例如定义宏 ``BSP_USING_SPI0`` 方可使用 SPI0 设备。注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 SPI 设备。 .. code-block:: C - + int spi_register(enum spi_index_type index, const char *name, uint16_t flag); - index 要注册的设备索引 @@ -146,7 +146,7 @@ SPI 设备接口全部遵循标准设备驱动管理层提供的接口。 ``index`` 用来选择 SPI 设备配置,一个 index 对应一个 SPI 设备配置,比如 ``SPI0_INDEX`` 对应 ``SPI0_CONFIG`` 配置,``index`` 有如下可选类型 .. code-block:: C - + enum spi_index_type { #ifdef BSP_USING_SPI0 @@ -162,7 +162,7 @@ SPI 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -186,11 +186,11 @@ SPI 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_close(struct device *dev); + int device_close(struct device *dev); - dev 设备句柄 - return 错误码,0 表示关闭成功,其他表示错误 - + **device_control** ^^^^^^^^^^^^^^^^^^^ @@ -198,7 +198,7 @@ SPI 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_control(struct device *dev, int cmd, void *args); + int device_control(struct device *dev, int cmd, void *args); - dev 设备句柄 - cmd 设备控制命令 @@ -246,7 +246,7 @@ SPI 设备除了标准的控制命令,还具有自己特殊的控制命令。 .. code-block:: C - int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); + int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); - dev 设备句柄 - pos 无作用 @@ -261,7 +261,7 @@ SPI 设备除了标准的控制命令,还具有自己特殊的控制命令。 .. code-block:: C - int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); + int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); - dev 设备句柄 - pos 无作用 @@ -284,7 +284,7 @@ SPI 设备除了标准的控制命令,还具有自己特殊的控制命令。 - dev 设备句柄 - args 接收发送缓冲区,数据类型为 uint8_t* - size 传输长度 - - event 中断事件类型 + - event 中断事件类型 SPI 设备 ``event`` 类型如下 diff --git a/docs/development_guide/source/api_reference/api_structure.rst b/docs/development_guide/source/api_reference/api_structure.rst index cbb00123..40eea4da 100644 --- a/docs/development_guide/source/api_reference/api_structure.rst +++ b/docs/development_guide/source/api_reference/api_structure.rst @@ -110,7 +110,7 @@ API 分层模型 .. code-block:: C - int device_register(struct device *dev, const char *name, uint16_t flag); + int device_register(struct device *dev, const char *name, uint16_t flag); - dev 设备句柄。 - name 设备名称。 @@ -133,7 +133,7 @@ API 分层模型 .. code-block:: C - int device_unregister(const char *name); + int device_unregister(const char *name); - dev 设备句柄 - name 要删除的设备名称 @@ -160,7 +160,7 @@ API 分层模型 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -184,11 +184,11 @@ API 分层模型 .. code-block:: C - int device_close(struct device *dev); + int device_close(struct device *dev); - dev 设备句柄 - return 错误码,0 表示关闭成功,其他表示错误 - + **device_control** ^^^^^^^^^^^^^^^^^^^ @@ -196,7 +196,7 @@ API 分层模型 .. code-block:: C - int device_control(struct device *dev, int cmd, void *args); + int device_control(struct device *dev, int cmd, void *args); - dev 设备句柄 - cmd 设备控制命令 @@ -230,7 +230,7 @@ API 分层模型 .. code-block:: C - int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); + int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); - dev 设备句柄 - pos 不同的设备 pos 的意义不同 @@ -245,7 +245,7 @@ API 分层模型 .. code-block:: C - int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); + int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); - dev 设备句柄 - pos 不同的设备 pos 的意义不同 diff --git a/docs/development_guide/source/api_reference/api_uart.rst b/docs/development_guide/source/api_reference/api_uart.rst index 8666481b..ac9785cd 100644 --- a/docs/development_guide/source/api_reference/api_uart.rst +++ b/docs/development_guide/source/api_reference/api_uart.rst @@ -20,7 +20,7 @@ UART 设备结构体定义 ------------------------ .. code-block:: C - + typedef struct uart_device { struct device parent; @@ -48,7 +48,7 @@ UART 设备结构体定义 .. code-block:: C - typedef enum + typedef enum { UART_DATA_LEN_5 = 0, /*!< Data length is 5 bits */ UART_DATA_LEN_6 = 1, /*!< Data length is 6 bits */ @@ -59,8 +59,8 @@ UART 设备结构体定义 ``stopbits`` 提供以下类型 .. code-block:: C - - typedef enum + + typedef enum { UART_STOP_ONE = 0, /*!< One stop bit */ UART_STOP_ONE_D_FIVE = 1, /*!< 1.5 stop bit */ @@ -70,8 +70,8 @@ UART 设备结构体定义 ``parity`` 提供以下类型 .. code-block:: C - - typedef enum + + typedef enum { UART_PAR_NONE = 0, /*!< No parity */ UART_PAR_ODD = 1, /*!< Parity bit is odd */ @@ -120,11 +120,11 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 **uart_register** ^^^^^^^^^^^^^^^^^^^^^^^^ - + ``uart_register`` 用来注册一个 UART 设备,在注册之前需要打开对应 UART 设备的宏定义。例如定义宏 ``BSP_USING_UART0`` 方可使用 ``UART0`` 设备,注册完成以后才可以使用其他接口,如果没有定义宏,则无法使用 ``UART0`` 设备。 .. code-block:: C - + int uart_register(enum uart_index_type index, const char *name, uint16_t flag); - index 要注册的设备索引 @@ -134,7 +134,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 ``index`` 用来选择 UART 设备配置,一个 index 对应一个 UART 设备配置,比如 ``UART0_INDEX`` 对应 ``UART0_CONFIG`` 配置,``index`` 有如下可选类型 .. code-block:: C - + enum uart_index_type { #ifdef BSP_USING_UART0 @@ -153,7 +153,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_open(struct device *dev, uint16_t oflag); + int device_open(struct device *dev, uint16_t oflag); - dev 设备句柄 - oflag 设备的打开方式 @@ -177,11 +177,11 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_close(struct device *dev); + int device_close(struct device *dev); - dev 设备句柄 - return 错误码,0 表示关闭成功,其他表示错误 - + **device_control** ^^^^^^^^^^^^^^^^^^^ @@ -189,7 +189,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_control(struct device *dev, int cmd, void *args); + int device_control(struct device *dev, int cmd, void *args); - dev 设备句柄 - cmd 设备控制命令 @@ -209,9 +209,9 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 +---------------------------------+---------------------+------------------------------+ |cmd |args |description | +=================================+=====================+==============================+ -|DEVICE_CTRL_SET_INT |uart_it_type |开启spi设备中断 | +|DEVICE_CTRL_SET_INT |uart_it_type |开启uart设备中断 | +---------------------------------+---------------------+------------------------------+ -|DEVICE_CTRL_CLR_INT |uart_it_type |关闭spi设备中断 | +|DEVICE_CTRL_CLR_INT |uart_it_type |关闭uart设备中断 | +---------------------------------+---------------------+------------------------------+ |DEVICE_CTRL_CONFIG |uart_param_cfg_t* |修改串口配置 | +---------------------------------+---------------------+------------------------------+ @@ -241,7 +241,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); + int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size); - dev 设备句柄 - pos 无作用 @@ -256,7 +256,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 .. code-block:: C - int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); + int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size); - dev 设备句柄 - pos 无作用 @@ -279,7 +279,7 @@ UART 设备接口全部遵循标准设备驱动管理层提供的接口。 - dev 设备句柄 - args 接收发送缓冲区,数据类型为 uint8_t* - size 传输长度 - - event 中断事件类型 + - event 中断事件类型 串口设备 ``event`` 类型如下 diff --git a/docs/development_guide/source/get_started/Linux_quick_start_ubuntu.rst b/docs/development_guide/source/get_started/Linux_quick_start_ubuntu.rst index 367736cd..b200541e 100644 --- a/docs/development_guide/source/get_started/Linux_quick_start_ubuntu.rst +++ b/docs/development_guide/source/get_started/Linux_quick_start_ubuntu.rst @@ -25,7 +25,7 @@ Linux OR WSL 环境开发指南 $ wget -c https://dev.bouffalolab.com/media/upload/download/riscv64-elf-x86_64-20210120.tar.gz $ mkdir -p riscv64-elf-20210120 $ tar -zxvf riscv64-elf-x86_64-20210120.tar.gz -C riscv64-elf-20210120 - $ sudo cp ~/riscv64-elf-20210120 /usr/bin + $ sudo cp -rf ~/riscv64-elf-20210120 /usr/bin $ echo "export PATH=\"$PATH:/usr/bin/riscv64-elf-20210120/bin\"" >> ~/.bashrc $ source ~/.bashrc @@ -39,9 +39,9 @@ Linux OR WSL 环境开发指南 $ sudo apt update $ sudo apt install make $ cd ~ - $ wget -c https://cmake.org/files/v3.19/cmake-3.19.3-Linux-x86_64.tar.gz + $ wget -c https://cmake.org/files/v3.19/cmake-3.19.3-Linux-x86_64.tar.gz $ tar -zxvf cmake-3.19.3-Linux-x86_64.tar.gz - $ sudo cp ~/cmake-3.19.3-Linux-x86_64 /usr/bin + $ sudo cp -rf ~/cmake-3.19.3-Linux-x86_64 /usr/bin $ echo "export PATH=\"$PATH:/usr/bin/cmake-3.19.3-Linux-x86_64/bin\"" >> ~/.bashrc $ source ~/.bashrc @@ -119,7 +119,7 @@ Linux OR WSL 环境开发指南 :linenos: $ sudo apt install picocom # 若已经安装请忽略 - $ picocom -b 2000000 /dev/ttyUSB0 + $ picocom -b 2000000 /dev/ttyUSB0 # 注意你的可用串口号 (如使用 Sipeed RV-debugger) - 按一下开发板上的 ``rst`` 按键,即可在串口终端中看到 ``hello world!`` diff --git a/docs/development_guide/source/get_started/Windows_quick_start_cdk.rst b/docs/development_guide/source/get_started/Windows_quick_start_cdk.rst index e739371a..684a971b 100644 --- a/docs/development_guide/source/get_started/Windows_quick_start_cdk.rst +++ b/docs/development_guide/source/get_started/Windows_quick_start_cdk.rst @@ -6,15 +6,15 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 本文档介绍了如何在 Windows 下使用 `平头哥半导体 `_ 开发的 CDK 集成开发环境, 来完成博流 BL702 系列 MCU 的相关软件开发工作。 -关于剑池 CDK ,这是一款由平头哥半导体开发打造的集成开发环境。它拥有和传统 MCU 开发环境十分近似的操作和设置,旨在不改变用户开发习惯的基础上,全面接入云端开发资源,结合图形化的 OSTracer、Profiling 等调试分析工具,加速用户产品开发。 +关于剑池 CDK ,这是一款由平头哥半导体开发打造的集成开发环境。它拥有和传统 MCU 开发环境十分近似的操作和设置,旨在不改变用户开发习惯的基础上,全面接入云端开发资源,结合图形化的 OSTracer、Profiling 等调试分析工具,加速用户产品开发 需要的软硬件环境 ----------------------------- - 剑池 CDK 软件 -- 一根 USB Type-A 数据线 -- 一个 CK-Link 仿真器 +- 一根 USB Type-A 数据线、一根 Type-C 数据线 +- 一个 CK-Link 仿真器 or 一个 Sipeed RV-Debugger Plus 调试器 - 一个 USB-TTL 串口模块 - 杜邦线若干 @@ -22,9 +22,9 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 下载剑池 CDK 软件安装包 ----------------------------- -- `剑池CDK `_ 软件安装可以从平头哥半导体 OCC 官网获取到。 +- `剑池CDK `_ 软件安装可以从平头哥半导体 OCC 官网获取到 -- 下载完成后,解压缩,双击 ``setup.exe``,按照其提示,完成软件安装即可。 +- 下载完成后,解压缩,双击 ``setup.exe``,按照其提示,完成软件安装即可 下载 bl_mcu_sdk 软件开发包 @@ -33,7 +33,7 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 - 从开源社区下载 bl_mcu_sdk 软件开发包。 - 可以使用 ``git clone`` 或者直接 ``download`` 的方式下 SDK - - 使用 ``git clone`` 前请确保已正确安装 ``git``,打开支持 ``git`` 的终端输入以下命令即可获取最新的 SDK。 + - 使用 ``git clone`` 前请确保已正确安装 ``git``,打开支持 ``git`` 的终端输入以下命令即可获取最新的 SDK .. code-block:: bash :linenos: @@ -47,16 +47,17 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 - 具体开发板的连接, 请参考 :ref:`connect_hardware` 部分 - 请确保开发板被正确设置后再进行下面的步骤 - + 测试 Hello World 工程 ------------------------------ +**使用 Sipeed RV-Debugger Plus 调试工程时请按照下面的步骤进行:** + 打开 Hello World ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- 获取到 SDK 后,进入 sdk 中的 ``examples/hellowd/helloworld/cdk`` 目录下,双击 ``helloworld.cdkproj``,即可打开 ``Helloworld`` 工程。 - +- 获取到 SDK 后,进入 sdk 中的 ``examples/hellowd/helloworld/cdk`` 目录下,双击 ``helloworld.cdkproj``,即可打开 ``Helloworld`` 工程 编译 Hello World ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,6 +67,78 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 helloworld.cdkproj +- 在活动工程下拉菜单选择 ``OpenOCD_Debug`` 工程,由于 Sipeed RV-Debugger Plus 是使用 OpenOCD 调试的,所以本教程基于 ``OpenOCD_Debug`` 工程; +- 如 Sipeed RV-Debugger Plus 没有正确安装驱动,请参考 :ref:`sipeed_rv_debugger_plus` 部分,设置好驱动程序,在进行下面的步骤 + +- 在 CDK 工具栏中,点击编译图标即可编译工程 + + - 点击 ``1`` 处 图标 ``Build Project`` 即可编译当前选中的工程 + - 点击 ``2`` 处 图标 ``Clean Project`` 即可清除上次编译的结果 + - 点击 ``3`` 处 图标 ``Flash Download`` 即可将编译好的代码下载到芯片中 (**使用 OpenOCD Debug 不能使用 Flash 下载功能**) + - 点击 ``4`` 处 图标 ``Start/Stop Debug`` 即可进行 debug 的相关操作 + - 也可以在 ``Project`` 中,右击工程名称,通过右击菜单中的选项对项目进行编译等操作 + + +烧写 Hello World +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- 在 CDK 中使用 OpenOCD 模式的调试方式时,暂不支持直接使用 CDK 相关 flash 工具下载代码,所以请使用 BL Dev Cube 工具进行程序烧写,烧写代码请参考 :ref:`bl_dev_cube` 部分进行 +- 代码烧写完成后使用 CDK 进行 Debug + +运行 Hello World +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- 从 CDK 的菜单栏 ``View->Serial Pane``,打开串口面板,在打开的 ``Serial Pane`` 中右击,进行串口设置,选择你对应的串口号和波特率 + +.. figure:: img/cdk4.png +.. figure:: img/cdk3.png + :alt: + + CDK Serial Pane setting + +- 按下板子上的 ``RST`` 按键,即可在串口中看到代码的运行结果 + +.. figure:: img/cdk6.png + :alt: + + HelloWorld! + + +调试 Hello World +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- 点击工具栏上方的 ``Start/Stop Debugger`` 按钮,进入 debug 界面,如下图所示 + +.. figure:: img/cdk10.png + :alt: + + Debug HelloWorld! + +- 在 debug 界面下,左侧的 ``Register`` 窗口中,可以查看 ``CPU`` 内部寄存器数据;右侧的 ``Peripherals`` 外设面板中, + 可以查看相应外设寄存器数据,外设的选择可以在顶部菜单栏的 ``Peripherals->System Viewer`` 选择; + 点击上方工具栏中的相关调试按钮可以进行断点设置、单步调试、指令单步和全速运行等操作。 + 当然这些操作都有相应的快捷键和快捷设置方法,详情请参考 ``CDK Help``,这里就不作过多介绍了。 + +- 我们点击单步运行按钮,运行代码,即可看到指示光标移动到下一句代码,同时可以看到串口面板中显示了我们输出的 ``Hello World!`` + + +**使用 CK-Link 调试工程时请按照下面的步骤进行:** + +打开 Hello World +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- 获取到 SDK 后,进入 sdk 中的 ``examples/hellowd/helloworld/cdk`` 目录下,双击 ``helloworld.cdkproj``,即可打开 ``Helloworld`` 工程 + +编译 Hello World +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. figure:: img/cdk1.png + :alt: + + helloworld.cdkproj + +- 在活动工程下拉菜单可以选择 ``CK_Link_Debug`` 或者 ``OpenOCD_Debug`` 工程,本教程基于 ``CK_Link_Debug`` 工程 + - 在 CDK 工具栏中,点击编译图标即可编译工程 - 点击 ``1`` 处 图标 ``Build Project`` 即可编译当前选中的工程 @@ -94,7 +167,7 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 :alt: CDK Project Setting - + - 点击 ``Project View`` 中的项目设置按钮,打开 ``Project Setting`` 窗口,或者通过右击 ``Project`` 名称中右击菜单栏中打开 - 在打开的 ``Project Setting`` 窗口中,选择 ``Flash`` 标签,配置需要的 Flash 算法 @@ -107,7 +180,7 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 - 在 ``Flash`` 标签中,点击 ``Add`` 按纽,在打开的列表中选择 ``bl70x_flash`` 算法,点击 ``Add`` 添加到工程中,``Flash`` 标签下的其他设置,如图所示: - 点击 OK 后,如配置正确,点击 ``Flash Download`` 即可将编译好的代码下载到芯片中 - + .. figure:: img/cdk5.png :alt: @@ -155,7 +228,7 @@ Windows 下使用 CDK (类 MDK Keil)开发指南 点击上方工具栏中的相关调试按钮可以进行断点设置、单步调试、指令单步和全速运行等操作。 当然这些操作都有相应的快捷键和快捷设置方法,详情请参考 ``CDK Help``,这里就不作过多介绍了。 -- 我们点击单步运行按钮,运行代码,即可看到指示光标移动到下一句代码,同时可以看到串口面板中显示了我们输出的 ``Hello World!`` +- 我们点击单步运行按钮,运行代码,即可看到指示光标移动到下一句代码,同时可以看到串口面板中显示了我们输出的 ``Hello World!`` .. figure:: img/cdk11.png :alt: diff --git a/docs/development_guide/source/get_started/Windows_quick_start_eclipse.rst b/docs/development_guide/source/get_started/Windows_quick_start_eclipse.rst index f0e506d8..b48d9d3a 100644 --- a/docs/development_guide/source/get_started/Windows_quick_start_eclipse.rst +++ b/docs/development_guide/source/get_started/Windows_quick_start_eclipse.rst @@ -144,7 +144,7 @@ Windows 下使用 Eclipse 开发指南 - 点击 eclipse 工具栏中的 ``Debug`` 按钮,进入 debug 配置窗口 - 选择 ``GDB SEGGER J-Link Debugging->Jlink_bl_mcu_sdk`` Debug 配置,在 ``C/C++ Application:`` 选项中选择需要调试的 ``.elf`` 文件 -- 先点击 ``Apply`` 后,在点击 ``Debug`` 即可进行 ``Debug`` +- 先点击 ``Apply`` 后,在点击 ``Debug`` 即可进行 ``Debug`` .. figure:: img/pic14.png :alt: @@ -153,7 +153,7 @@ Windows 下使用 Eclipse 开发指南 .. figure:: img/pic15.png :alt: - + Eclipse Debugging diff --git a/docs/development_guide/source/get_started/bl_dev_cube.rst b/docs/development_guide/source/get_started/bl_dev_cube.rst index 19c8e7b9..c239cd67 100644 --- a/docs/development_guide/source/get_started/bl_dev_cube.rst +++ b/docs/development_guide/source/get_started/bl_dev_cube.rst @@ -59,17 +59,17 @@ BLDevCube 烧录工具指南 - 硬件连接需要更改为支持 Openocd 的调试器连接(本教程以 Sipeed RV Debugger 为例): - 1. 首先将 RV 调试器连接到电脑的 USB 接口,打开设备管理器,会发现调试器被识别为两个串口(注:不是开发板上的串口) - + .. figure:: img/sipeed_rv_debugger_1.png - 2. 从 sipeed 下载 ``zadig-2.4`` 替换驱动程序。下载地址:`http://dl.sipeed.com/MAIX/tools/sipeed-rv-debugger/zadig-2.4.exe `_ - 3. 下载好双击打开 ``zadig-2.4.exe``,选择 Options 勾选 List All Devices. - + .. figure:: img/sipeed_rv_debugger_3.png - + - 4. 找到 JTAG Debugger(Interface 0),然后选择替换的驱动为 WinUSB 点击 Replace Driver 替换 - 5. 再次打开设备管理器, 看到其中一个串口被替换成通用串行总线设备就说明安装成功 - + .. figure:: img/sipeed_rv_debugger_2.png - 6.将调试器的 JTAG 引脚与开发板的 JTAG 引脚连接起来 diff --git a/docs/development_guide/source/get_started/connecting_hardware.rst b/docs/development_guide/source/get_started/connecting_hardware.rst index 4c6abc98..7887e77d 100644 --- a/docs/development_guide/source/get_started/connecting_hardware.rst +++ b/docs/development_guide/source/get_started/connecting_hardware.rst @@ -20,8 +20,8 @@ BL706_IOT 开发板 bl706-iot board CK-Link ------------------------------- JTAG_TDI <--> TDI - JTAG_TDO <--> TDO - JTAG_TCK <--> TCK + JTAG_TDO <--> TDO + JTAG_TCK <--> TCK JTAG_TMS <--> TMS VDD33 <--> VREF GND <--> GND @@ -45,8 +45,8 @@ BL706_IOT 开发板 bl706-iot board j-link ------------------------------- JTAG_TDI <--> TDI - JTAG_TDO <--> TDO - JTAG_TCK <--> TCK + JTAG_TDO <--> TDO + JTAG_TCK <--> TCK JTAG_TMS <--> TMS VDD33 <--> VTref GND <--> GND @@ -82,16 +82,73 @@ BL706_IOT 开发板 - 烧写方法同上 -BL702_AVB 开发板 +BL706_AVB 开发板 -------------------------- +.. important:: BL706_AVB 开发板有多个引脚存在复用情况,请仔细检查所需功能引脚是否被复用了;FUNC1:「Default: PIX; Connect: I2S/JTAG」,FUNC2:「Default: I2S; Connect: SPI」; **如果需要调试,请务必记得将 FUNC1 跳帽连接** + +使用 Sipeed RV-Debugger Plus 烧写、调试连接方法 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- 将 BL706_AVB 开发板先供电 +- 将 RV-Debugger Plus 调试器连接到电脑 USB 口,如没有正确安装驱动,请参考 :ref:`sipeed_rv_debugger_plus` 部分,设置好驱动程序,在进行下面的步骤 +- 将调试器和 BL706_AVB 开发板使用排线连接起来(如下图所示) + +.. important:: 使用调试功能是一定要将 FUNC1 跳帽连接,否则引脚被复用其他功能,不能使用 JTAG 功能;串口功能可以正常使用 + +.. figure:: img/bl706_avb_rv_debugger_plus.png + :alt: + + RV-Debugger connect bl706_avb board + 使用 CK-Link 烧写、调试连接方法 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- ``TO DO`` +- 将 CK-Link USB 接口使用合适的 USB 数据线正确连接到 PC 主机 +- 将 bl706_avb 开发板的 FUNC1 跳帽短接 +- 将 ``HD8`` 组的引脚使用排线引到转接板 +- 将转接板的标准 ``JTAG`` 引脚使用杜邦线与 ``CK-Link`` 对应的 ``JTAG`` 引脚连接起来 +- 若没有使用 CK-Link 给开发板供电,需要给开发板单独供电 + +:: + + bl706-avb board CK-Link + ------------------------------- + JTAG_TDI <--> TDI + JTAG_TDO <--> TDO + JTAG_TCK <--> TCK + JTAG_TMS <--> TMS + VDD33 <--> VREF + GND <--> GND + + +.. figure:: img/bl706_avb_ck_link.png + :alt: + + ck_link connect bl706_avb board 使用串口烧写程序连接方法 ^^^^^^^^^^^^^^^^^^^^^^^^^^ -- ``TO DO`` +- 使用串口烧写前,请确保正确安装了 ``Bouffalo Lab Dev Cube`` 或命令行烧写工具 + + - 使用 ``Type-C USB`` 数据线 or ``Mini USB`` 数据线连接到开发板上对应的 ``Type-C`` 接口 or ``Mini`` 接口上。 + - 按下开发板上的 ``Boot`` 键,不要释放 + - 按下开发板上的 ``RST`` 键,此时已经进入 ``Boot ROM``,可以释放两个按键 + - 这时就可以从 ``Bouffalo Lab Dev Cube`` 中看到相应的串口 ``COM`` 号,如没有出现,请点击 ``Refresh`` 按钮刷新一下 + + +- 如没有合适的数据线,也可以使用一些常见的 ``USB-TTL`` 模块,连接到开发板的 ``UART0`` 端口进行烧写。 ``UART0`` 在 ``HD12`` 组上,连接方法如下: + +- 如果使用 Sipeed RV-Debugger Plus 通过排线连接了 BL706_AVB 开发板,则也可以使用 Sipeed RV Debugger Plus 的串口 + +:: + + USB-TTL BL706_AVB + ---------------------- + TXD <--> RX0 + RXD <--> TX0 + GND <--> GND + +- diff --git a/docs/development_guide/source/get_started/get_started.rst b/docs/development_guide/source/get_started/get_started.rst index 40441314..c2b5afa4 100644 --- a/docs/development_guide/source/get_started/get_started.rst +++ b/docs/development_guide/source/get_started/get_started.rst @@ -4,30 +4,30 @@ 硬件环境准备 ----------------------------- -- 一块 BL702 系列 MCU 的开发板: +- 至少有一块 BL702 系列 MCU 的开发板: - - BL706_IOT 开发板, or + - BL706_IOT 开发板 - BL706_AVB 开发板 BL706_Iot 开发板如下图所示 .. figure:: img/bl702_iot.png :alt: - + BL706_IoT BL706_AVB 开发板如下图所示 .. figure:: img/bl706_avb.png :alt: - + BL706_AVB - 一个支持标准 JTAG 功能的调试器,下面几款调试器中选择一款与开发环境适合即可: - CK-Link 仿真器 - Jlink V11 仿真器 - - Sipeed USB-JTAG/TTL 调试器 + - Sipeed RV-Debugger Plus 调试器 - Bouffalo Lab Debugger 调试器 - 一台 PC 主机(运行 Windows 或者 Linux 系统) @@ -35,9 +35,66 @@ BL706_AVB 开发板如下图所示 软件环境准备 -------------------------------- -为了更好的进行 BL702 系列 MCU 的开发,建议您应当具备以下开发环境: +为了更好的进行 BL702 系列 MCU 的开发,建议您应当至少具备以下一种开发环境: -- Windows 使用 `CDK `_ 环境开发 (建议 Windows 7 以上版本。) ,or -- `Windows `_ 使用 Eclipse 环境开发 (建议 Windows 7 以上版本。) ,or +- Windows 使用 `CDK `_ 环境开发 (建议 Windows 7 以上版本) +- `Windows `_ 使用 Eclipse 环境开发 (建议 Windows 7 以上版本) - `Linux `_ (建议使用 Ubuntu 18 以上的 LTS 版本) + +.. _sipeed_rv_debugger_plus: + +调试器驱动安装设置 +----------------------------- + +- 本节主要介绍 **Sipeed RV-Debugger Plus** 调试器的驱动安装设置,若使用 **CK-Link** 或者 **J-Link** 无需阅读本节内容 + +.. figure:: img/sipeed_rv_debugger_plus.png + :alt: + + Sipeed RV-Debugger plus + +**Windows** + +- Sipeed RV-Debugger Plus 调试器在 Windows 系统中所以时我们需要将驱动更换为 ``Win USB`` 驱动 + + - 1. 首先,将调试器 Type-C USB 接口使用 USB 数据线连接到 PC 主机,打开 PC 的设备管理器,在端口一栏可以看到调试器被识别为两个串口(*注:不是开发板上的串口*),或者在 ``通用串行总线控制器`` 看到 ``USB Serial Converter A`` 和 ``USB Serial Converter B`` + + .. figure:: img/sipeed_rv_debugger_1.png + + .. figure:: img/sipeed_rv_debugger_4.png + + - 2. 从 sipeed 网站下载 ``zadig-2.4`` 替换驱动程序。下载地址:`http://dl.sipeed.com/MAIX/tools/sipeed-rv-debugger/zadig-2.4.exe `_ + - 3. 下载好双击打开 ``zadig-2.4.exe``,选择 Options 勾选 List All Devices. + + .. figure:: img/sipeed_rv_debugger_3.png + + - 4. 找到 JTAG Debugger(Interface 0),然后选择替换的驱动为 ``WinUSB`` 点击 Replace Driver 替换 + - 5. 再次打开设备管理器, 看到其中一个串口被替换成通用串行总线设备就说明安装成功 + + .. figure:: img/sipeed_rv_debugger_2.png + + - 6. 到这里 Sipeed RV-Debugger Plus 的设备驱动就更换好了,接下来就可以愉快的玩耍啦~ + + +**可能出现的问题:** + +.. caution:: 1. 调试器接上时没有出现两个串口,调试器上有一个 LED 常亮,那么应该是进入了 Boot 模式。请将调试器断电重新上电,注意先不要将调试器连接到目标板;调试器上电后,正常情况下两个 LED 灯会闪烁一下熄灭;此时再看一下任务管理器中的设备是否正确。 + +.. caution:: 2. 在设备管理器中没有看到任何串口,但是在``通用串行总线控制器``中看到 ``USB Serial Converter A`` 和 ``USB Serial Converter B``;遇到这种情况,请到 `FTDI 官网 `_ 下载与系统匹配的驱动,将 ``USB Serial Converter B`` 重新安装为串口;``USB Serial Converter A`` 也即 Interface 0,使用 ``zadig-2.4.exe`` 替换为 WinUSB 驱动。 + +**Linux** + +- 安装 Openocd 及其需要的依赖项 + +.. code-block:: bash + + $ apt install openocd libusb-dev libftdi-dev libhidapi-dev + +- 重新插拔调试器使修改生效 +- 打开 Terminal,在终端中输入 lsusb 命令,即可看到如下信息的设备 + +.. code-block::bash + + $ Bus 001 Device 003: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC + diff --git a/docs/development_guide/source/get_started/img/bl706_avb_ck_link.png b/docs/development_guide/source/get_started/img/bl706_avb_ck_link.png new file mode 100644 index 00000000..da39cae4 Binary files /dev/null and b/docs/development_guide/source/get_started/img/bl706_avb_ck_link.png differ diff --git a/docs/development_guide/source/get_started/img/bl706_avb_rv_debugger_plus.png b/docs/development_guide/source/get_started/img/bl706_avb_rv_debugger_plus.png new file mode 100644 index 00000000..8deac670 Binary files /dev/null and b/docs/development_guide/source/get_started/img/bl706_avb_rv_debugger_plus.png differ diff --git a/docs/development_guide/source/get_started/img/cdk1.png b/docs/development_guide/source/get_started/img/cdk1.png index ef477b17..7175dc0a 100644 Binary files a/docs/development_guide/source/get_started/img/cdk1.png and b/docs/development_guide/source/get_started/img/cdk1.png differ diff --git a/docs/development_guide/source/get_started/img/sipeed_rv_debugger_3.png b/docs/development_guide/source/get_started/img/sipeed_rv_debugger_3.png index fea51b2e..4db6ab8c 100644 Binary files a/docs/development_guide/source/get_started/img/sipeed_rv_debugger_3.png and b/docs/development_guide/source/get_started/img/sipeed_rv_debugger_3.png differ diff --git a/docs/development_guide/source/get_started/img/sipeed_rv_debugger_4.png b/docs/development_guide/source/get_started/img/sipeed_rv_debugger_4.png new file mode 100644 index 00000000..f971757a Binary files /dev/null and b/docs/development_guide/source/get_started/img/sipeed_rv_debugger_4.png differ diff --git a/docs/development_guide/source/get_started/img/sipeed_rv_debugger_plus.png b/docs/development_guide/source/get_started/img/sipeed_rv_debugger_plus.png new file mode 100644 index 00000000..89673229 Binary files /dev/null and b/docs/development_guide/source/get_started/img/sipeed_rv_debugger_plus.png differ diff --git a/docs/development_guide/source/index.rst b/docs/development_guide/source/index.rst index 03591fe4..8fa042ab 100644 --- a/docs/development_guide/source/index.rst +++ b/docs/development_guide/source/index.rst @@ -26,7 +26,7 @@ BL MCU SDK 将为您提供博流 BL70X 系列 MCU 开发的全方位支持。 - + .. toctree:: :maxdepth: 1 :caption: API 手册 @@ -42,28 +42,31 @@ BL MCU SDK 将为您提供博流 BL70X 系列 MCU 开发的全方位支持。 api_reference/api_spi api_reference/api_adc api_reference/api_dac + .. api_reference/api_ble + + - .. toctree:: :maxdepth: 1 :caption: 基础外设例程 :numbered: - samples/basic samples/blink_demo - samples/basic samples/button_demo - samples/basic samples/breath_pwm_demo - samples/basic samples/uart_loopback_demo - samples/basic samples/mtimer_demo - samples/basic samples/dma_m2m_demo - samples/basic samples/i2c_eeprom_demo - samples/basic samples/spi_lcd_demo - samples/basic samples/adc_key_demo + samples/basic samples/gpio/index + samples/basic samples/uart/index + samples/basic samples/pwm/index + samples/basic samples/mtimer/index + samples/basic samples/dma/index + samples/basic samples/spi/index + samples/basic samples/i2c/index + samples/basic samples/adc/index + + .. toctree:: :maxdepth: 1 :caption: 进阶例程 :numbered: - + samples/advance samples/shell_demo samples/advance samples/fatfs_demo samples/advance samples/lowpower_demo diff --git a/docs/development_guide/source/samples/advance samples/ble_scan_demo.rst b/docs/development_guide/source/samples/advance samples/ble_scan_demo.rst index 15c0b16b..922974af 100644 --- a/docs/development_guide/source/samples/advance samples/ble_scan_demo.rst +++ b/docs/development_guide/source/samples/advance samples/ble_scan_demo.rst @@ -48,7 +48,7 @@ BLE client 软件实现 uint8_t buf[20] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; while(1) { - k_sem_take(&write_data_poll_sem, K_FOREVER); + k_sem_take(&write_data_poll_sem, K_FOREVER); BT_WARN("ble_write_data\r\n"); // Send data to server error = bt_gatt_write_without_response(ble_tp_conn,char_hdl.tp_wr_hdl,buf,20,0); @@ -75,7 +75,7 @@ BLE server 软件实现 :linenos: int ble_start_adv(void) - { + { struct bt_le_adv_param adv_param = { //options:3, connectable undirected, adv one time .options = 3, \ @@ -83,7 +83,7 @@ BLE server 软件实现 .interval_max = BT_GAP_ADV_FAST_INT_MAX_3, \ }; - + char *adv_name = "BL_TEST_01"; // This name must be the same as adv_name in ble_central uint8_t data[1] = {(BT_LE_AD_LIMITED | BT_LE_AD_NO_BREDR)}; uint8_t data_uuid[2] = {0x12, 0x18};//0x1812 @@ -119,8 +119,8 @@ BLE server 软件实现 char data[244] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09}; k_sem_give(¬ify_poll_sem); while(1) - { - k_sem_take(¬ify_poll_sem, K_FOREVER); + { + k_sem_take(¬ify_poll_sem, K_FOREVER); //send data to client err = bt_gatt_notify(ble_tp_conn, get_attr(BT_CHAR_BLE_TP_NOT_ATTR_VAL_INDEX), data, (tx_mtu_size - 3)); BT_WARN("ble tp send notify : %d\n", err); @@ -168,7 +168,7 @@ BLE server 软件实现 .. figure:: img/ble_server.png :alt: - + - **手机连接 bl702** .. figure:: img/phone_connect.jpg diff --git a/docs/development_guide/source/samples/advance samples/boot2_iap_info.rst b/docs/development_guide/source/samples/advance samples/boot2_iap_info.rst index d1b01764..929138af 100644 --- a/docs/development_guide/source/samples/advance samples/boot2_iap_info.rst +++ b/docs/development_guide/source/samples/advance samples/boot2_iap_info.rst @@ -25,4 +25,4 @@ bl_mcu_sdk 开源了 boot2_iap 的软件源码,用户可以到 examples/boot2_ 实验现象 ----------------------------- -使用 Dev Cube 完成 IAP 功能的具体步骤,请参阅 `DevCube用户手册 `_ 章节。 \ No newline at end of file +使用 Dev Cube 完成 IAP 功能的具体步骤,请参阅 `DevCube用户手册 `_ 章节。 \ No newline at end of file diff --git a/docs/development_guide/source/samples/advance samples/img/shell_demo.gif b/docs/development_guide/source/samples/advance samples/img/shell_demo.gif new file mode 100644 index 00000000..7cbd5138 Binary files /dev/null and b/docs/development_guide/source/samples/advance samples/img/shell_demo.gif differ diff --git a/docs/development_guide/source/samples/advance samples/img/xShell页面.png b/docs/development_guide/source/samples/advance samples/img/xShell页面.png deleted file mode 100644 index 5a16356f..00000000 Binary files a/docs/development_guide/source/samples/advance samples/img/xShell页面.png and /dev/null differ diff --git a/docs/development_guide/source/samples/advance samples/img/低功耗示意图.png b/docs/development_guide/source/samples/advance samples/img/低功耗示意图.png deleted file mode 100644 index 93fcc569..00000000 Binary files a/docs/development_guide/source/samples/advance samples/img/低功耗示意图.png and /dev/null differ diff --git a/docs/development_guide/source/samples/advance samples/lowpower_demo.rst b/docs/development_guide/source/samples/advance samples/lowpower_demo.rst index 40d62cec..9833a92d 100644 --- a/docs/development_guide/source/samples/advance samples/lowpower_demo.rst +++ b/docs/development_guide/source/samples/advance samples/lowpower_demo.rst @@ -5,13 +5,13 @@ LowPower 低功耗评估 ------------------------ 博流系列芯片拥有丰富的低功耗特性,以适配不同的低功耗应用场合。为了方便用户快速的评测使用 bl 系列 MCU 低功耗性能 bl_mcu_sdk 提供了一套抽象的低功耗接口,将低功耗等级分为四个等级,分别为 - + 1. Running : Running 为 CPU 正常运行时的功耗,由客户应用代码执行的功能决定功耗。 - + 2. WFI :WFI 模式,CPU 的 clock 处于被 Gating 状态,CPU 停止运行,当用户退出WFI模式的时候程序将会继续运行。 - + 3. PDS : PDS 模式,关闭了芯片上大多数电源域,同时关闭了 CPU,和 CPU 处于同一个电源域的 ITCM,DTCM 等 RAM 不可使用,只有 64K 的 OCTAM 可以保存数据,可以通过内部 RTC 进行唤醒,或者使用 GPIO 引脚(在 GPIO 电源域没有关闭的情况下)唤醒。 - + 4. HBN : HBN 模式,关闭了芯片上绝大多数电源域,关闭了 CPU 以及 64K OCRAM,只有位于 AON 域的 4K RAM 可以保存数据,可以通过内部 RTC 进行唤醒,或者使用特定的唤醒引脚(位于 AON 域的引脚)唤醒。 @@ -59,7 +59,7 @@ bl_mcu_sdk 提供了一个简单的低功耗参考示例(bl_mcu_sdk examples/pow - 电流表 - 一台 PC 主机(运行 Windows 或者 Linux 系统) - TTL 转 USB - + 如下图所示,将电流表串联进入 bl706 模组的供电线路,通过 PC 端的串口调试助手软件,下发不同的低功耗指令,使得 bl706 进入对应的低功耗模式 观察电流表示值,完成评估。 diff --git a/docs/development_guide/source/samples/advance samples/shell_demo.rst b/docs/development_guide/source/samples/advance samples/shell_demo.rst index 4142f385..6ec8fee3 100644 --- a/docs/development_guide/source/samples/advance samples/shell_demo.rst +++ b/docs/development_guide/source/samples/advance samples/shell_demo.rst @@ -1,32 +1,198 @@ SHELL 命令行调试 ==================== -为方便用户使用 pc 或者其他控制器对开发板进行功能的调试(非仿真器调试),这里提供了 shell 命令行组件,类似于在 linux 下进行命令行操作。用户在 PC 端或者其他控制端进行命令的发送,通过串口、usb、以太网、蓝牙、wifi等方式,将数据发送给开发板的 shell 中,shell 会读取接收的命令进行解析并对已经注册的内部函数扫描,扫描到与之匹配的函数以后,执行匹配的函数,并实时返回传入的键值和函数执行的结果给 pc or 控制端。其中需要注意,控制器端需要发送标准键盘的键值。 +为方便用户使用 pc 或者其他控制器对开发板进行功能的调试(非仿真器调试),我们为用户提供了 shell 命令行组件,类似于在 linux 下进行命令行操作。用户在 PC 端或者其他控制端进行命令的发送,通过串口、usb、以太网、蓝牙、wifi等方式,将数据发送给开发板的 shell 中,shell 会读取接收的命令进行解析并对已经注册的内部函数扫描,扫描到与之匹配的函数以后,执行匹配的函数,并实时返回传入的键值和函数执行的结果给 pc or 控制端。其中需要注意,控制器端需要发送标准键盘的键值。 本 demo 将演示如何使用 **shell** 通过串口进行命令行调试。 +本 shell 组件有以下功能: + +- 支持标准键盘字符控制 +- 支持命令自动补全 +- 支持上下键查看历史命令 +- 支持左右键修改命令 +- 支持文件系统、网络系统调试 + 准备工具 ----------------------- -- pc控制端使用串口终端软件:xshell或者mobaxterm +- pc控制端使用串口终端软件:xshell 或者 mobaxterm - 连接介质:usb转串口 or 网络 or usb +硬件连接 +----------------------------- + +本 demo 基于 BL706_IOT 开发板,连接方式如下 + +:: + + GPIO function GPIO pin + ---------------------------------- + UART0_TX <--> GPIO14 + UART0_RX <--> GPIO15 + + 软件实现 ------------------------- -串口中使用 SHELL +shell 移植到串口 ^^^^^^^^^^^^^^^^^^^^ -BLE 中使用 SHELL -^^^^^^^^^^^^^^^^^^^^ +- 软件代码见 ``examples/shell`` + +.. code-block:: C + :linenos: + + #define BSP_UART_CLOCK_SOURCE ROOT_CLOCK_SOURCE_PLL_96M + #define BSP_UART_CLOCK_DIV 0 + +- 配置 ``UART`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` + +.. code-block:: C + :linenos: + + #define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX + #define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX + +- 配置 ``UART`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` + +.. code-block:: C + :linenos: + + #define BSP_USING_UART0 + + #if defined(BSP_USING_UART0) + #ifndef UART0_CONFIG + #define UART0_CONFIG \ + { \ + .id = 0, \ + .baudrate = 2000000,\ + .databits = UART_DATA_LEN_8, \ + .stopbits = UART_STOP_ONE, \ + .parity = UART_PAR_NONE, \ + .fifo_threshold = 1, \ + } + #endif + #endif + +- 使能 ``BSP_USING_UART0`` 并配置 ``UART`` 设备配置,见 ``bsp/board/bl706_iot/peripheral_config.h`` + +.. code-block:: C + :linenos: + + bflb_platform_init(); + +- 在 ``bflb_platform_init`` 函数中,我们已经注册并且打开了一个调试用的串口设备,给用户实现一个 ``MSG`` 的基本功能用作打印输出报文。具体实现如下 + +.. code-block:: C + :linenos: + + uart_register(board_get_debug_uart_index(), "debug_log", DEVICE_OFLAG_RDWR); + struct device *uart = device_find("debug_log"); + + if (uart) + { + device_open(uart, DEVICE_OFLAG_STREAM_TX | DEVICE_OFLAG_INT_RX); + device_set_callback(uart, NULL); + device_control(uart, DEVICE_CTRL_CLR_INT, (void *)(UART_RX_FIFO_IT)); + } + +- 首先调用 ``uart_register`` 函数注册 ``UART`` 设备,当前注册 ``UART0`` +- 然后通过 ``find`` 函数找到设备对应的句柄,保存于 ``uart`` 句柄中 +- 最后使用 ``device_open`` 以轮询发送和中断接收来打开 ``uart`` 设备,默认关闭中断并且不注册接收中断回调函数 + +.. code-block:: C + :linenos: + + struct device *uart = device_find("debug_log"); + if (uart) { + device_set_callback(uart, shell_irq_callback); + device_control(uart, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT)); + } + +- 通过 ``device_set_callback`` 函数,为 ``UART0`` 注册接收中断服务函数。通过 ``device_control`` 函数打开 ``UART_RX_FIFO_IT`` 中断 + +.. code-block:: C + :linenos: + + void shell_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state) + { + uint8_t data; + if (state == UART_EVENT_RX_FIFO) { + data = *(uint8_t *)args; + shell_handler(data); + } + } + +- 中断回调函数中,判断 ``state`` 是否是 ``UART_EVENT_RX_FIFO``,是的话就将接收的字节传入 ``shell_handler`` 函数。 + + +.. code-block:: C + :linenos: + + shell_init(); + +- 调用 ``shell_init`` 初始化 shell 组件。 -以太网中使用 SHELL -^^^^^^^^^^^^^^^^^^^^ SHELL 命令注册 ^^^^^^^^^^^^^^^^^^^^ +shell 命令注册使用以下两个宏 + +- **SHELL_CMD_EXPORT** + +``SHELL_CMD_EXPORT`` 有两个参数,``command`` 代表需要注册的函数名,pc 或者控制器将发送 ``command`` 对设备进行命令控制,desc`` 是对该注册函数的描述, + +.. code-block:: C + :linenos: + + void hellowd() + { + MSG("hello World\r\n"); + } + SHELL_CMD_EXPORT(hellowd, hellowd test) + +- **SHELL_CMD_EXPORT_ALIAS** + +``SHELL_CMD_EXPORT_ALIAS`` 有三个参数,``command`` 代表需要注册的函数名,``alias`` 是对该注册函数名重命名,pc 或者控制器将发送 ``alias`` 对设备进行命令控制,``desc`` 是对该注册函数的描述, + +.. code-block:: C + :linenos: + + void hellowd() + { + MSG("hello World\r\n"); + } + SHELL_CMD_EXPORT_ALIAS(hellowd, hellwd,hellowd test) + + 编译和烧录 ----------------------------- +- **CDK 编译** + + 打开项目中提供的工程文件:shell.cdkproj + + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 + +- **命令行编译** + +.. code-block:: bash + :linenos: + + $ cd /bl_mcu_sdk + $ make BOARD=bl706_iot APP=shell SUPPORT_SHELL=y + +- **烧录** + + 详见 :ref:`bl_dev_cube` + + 实验现象 ----------------------------- + +.. figure:: img/shell_demo.gif + :alt: + +shell test + diff --git a/docs/development_guide/source/samples/basic samples/adc_key_demo.rst b/docs/development_guide/source/samples/basic samples/adc/adc_key_demo.rst similarity index 95% rename from docs/development_guide/source/samples/basic samples/adc_key_demo.rst rename to docs/development_guide/source/samples/basic samples/adc/adc_key_demo.rst index 10a4b30a..bc5cbd5a 100644 --- a/docs/development_guide/source/samples/basic samples/adc_key_demo.rst +++ b/docs/development_guide/source/samples/basic samples/adc/adc_key_demo.rst @@ -31,14 +31,14 @@ ADC - 按键检测电压 #define BSP_ADC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK #define BSP_ADC_CLOCK_DIV 0 -- 配置 ``ADC`` 设备时钟源,见 ``bsp/board/bl706_avb/clock_config.h`` +- 配置 ``ADC`` 设备时钟源,见 ``bsp/board/bl706_avb/clock_config.h`` .. code-block:: C :linenos: #define CONFIG_GPIO18_FUNC GPIO_FUN_ADC -- 配置 ``ADC`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` +- 配置 ``ADC`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` .. code-block:: C :linenos: @@ -78,7 +78,7 @@ ADC - 按键检测电压 ADC_DEV(adc_key)->continuous_conv_mode = ENABLE; device_open(adc_key, DEVICE_OFLAG_STREAM_RX); device_control(adc_key,DEVICE_CTRL_ADC_CHANNEL_CONFIG,&adc_channel_cfg); - + }else{ MSG("device open failed\r\n"); } @@ -111,7 +111,7 @@ ADC - 按键检测电压 - **CDK工具编译** 打开项目中提供的工程文件:adc_key.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** diff --git a/docs/development_guide/source/samples/basic samples/img/adc_key_demo.png b/docs/development_guide/source/samples/basic samples/adc/img/adc_key_demo.png similarity index 100% rename from docs/development_guide/source/samples/basic samples/img/adc_key_demo.png rename to docs/development_guide/source/samples/basic samples/adc/img/adc_key_demo.png diff --git a/docs/development_guide/source/samples/basic samples/img/adc_key_result.png b/docs/development_guide/source/samples/basic samples/adc/img/adc_key_result.png similarity index 100% rename from docs/development_guide/source/samples/basic samples/img/adc_key_result.png rename to docs/development_guide/source/samples/basic samples/adc/img/adc_key_result.png diff --git a/docs/development_guide/source/samples/basic samples/adc/index.rst b/docs/development_guide/source/samples/basic samples/adc/index.rst new file mode 100644 index 00000000..bc04aa5b --- /dev/null +++ b/docs/development_guide/source/samples/basic samples/adc/index.rst @@ -0,0 +1,9 @@ +======================= +ADC 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + ADC - 按键检测电压 \ No newline at end of file diff --git a/docs/development_guide/source/samples/basic samples/dma_m2m_demo.rst b/docs/development_guide/source/samples/basic samples/dma/dma_m2m_demo.rst similarity index 95% rename from docs/development_guide/source/samples/basic samples/dma_m2m_demo.rst rename to docs/development_guide/source/samples/basic samples/dma/dma_m2m_demo.rst index fc41cae1..9be58654 100644 --- a/docs/development_guide/source/samples/basic samples/dma_m2m_demo.rst +++ b/docs/development_guide/source/samples/basic samples/dma/dma_m2m_demo.rst @@ -56,7 +56,7 @@ DMA - RAM间数据搬运 .. code-block:: C :linenos: - dma_reload(dma,(uint32_t)dma_src_buffer,(uint32_t)dma_dst_buffer,8000); + dma_reload(dma,(uint32_t)dma_src_buffer,(uint32_t)dma_dst_buffer,8000); dma_channel_start(dma); - 调用 ``dma_reload`` 函数对dma 通道0的配置进行补充,``DMA0_CH0_CONFIG`` 中已经补充了一部分配置,这边主要补充源数据地址和目标数据地址以及传输总长度 @@ -92,7 +92,7 @@ DMA - RAM间数据搬运 - **CDK 编译** 打开项目中提供的工程文件:dma_m2m.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** diff --git a/docs/development_guide/source/samples/basic samples/dma/index.rst b/docs/development_guide/source/samples/basic samples/dma/index.rst new file mode 100644 index 00000000..8cb8e35f --- /dev/null +++ b/docs/development_guide/source/samples/basic samples/dma/index.rst @@ -0,0 +1,9 @@ +======================= +DMA 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + DMA - RAM间数据搬运 \ No newline at end of file diff --git a/docs/development_guide/source/samples/basic samples/blink_demo.rst b/docs/development_guide/source/samples/basic samples/gpio/blink_demo.rst similarity index 100% rename from docs/development_guide/source/samples/basic samples/blink_demo.rst rename to docs/development_guide/source/samples/basic samples/gpio/blink_demo.rst diff --git a/docs/development_guide/source/samples/basic samples/button_demo.rst b/docs/development_guide/source/samples/basic samples/gpio/button_demo.rst similarity index 95% rename from docs/development_guide/source/samples/basic samples/button_demo.rst rename to docs/development_guide/source/samples/basic samples/gpio/button_demo.rst index cff8dd8f..7abe7bbf 100644 --- a/docs/development_guide/source/samples/basic samples/button_demo.rst +++ b/docs/development_guide/source/samples/basic samples/gpio/button_demo.rst @@ -42,7 +42,7 @@ GPIO 中断 - 按键检测 - **CDK 编译** 打开项目中提供的工程文件:gpio_int.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** diff --git a/docs/development_guide/source/samples/basic samples/gpio/img/blink_breath_sch.png b/docs/development_guide/source/samples/basic samples/gpio/img/blink_breath_sch.png new file mode 100644 index 00000000..25786009 Binary files /dev/null and b/docs/development_guide/source/samples/basic samples/gpio/img/blink_breath_sch.png differ diff --git a/docs/development_guide/source/samples/basic samples/img/button_sch.png b/docs/development_guide/source/samples/basic samples/gpio/img/button_sch.png similarity index 100% rename from docs/development_guide/source/samples/basic samples/img/button_sch.png rename to docs/development_guide/source/samples/basic samples/gpio/img/button_sch.png diff --git a/docs/development_guide/source/samples/basic samples/gpio/index.rst b/docs/development_guide/source/samples/basic samples/gpio/index.rst new file mode 100644 index 00000000..d5f7805f --- /dev/null +++ b/docs/development_guide/source/samples/basic samples/gpio/index.rst @@ -0,0 +1,10 @@ +======================= +GPIO 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + GPIO 输出 - 流水灯 + GPIO 中断 - 流水灯 \ No newline at end of file diff --git a/docs/development_guide/source/samples/basic samples/i2c_eeprom_demo.rst b/docs/development_guide/source/samples/basic samples/i2c/i2c_eeprom_demo.rst similarity index 94% rename from docs/development_guide/source/samples/basic samples/i2c_eeprom_demo.rst rename to docs/development_guide/source/samples/basic samples/i2c/i2c_eeprom_demo.rst index 05767cd8..8df3042a 100644 --- a/docs/development_guide/source/samples/basic samples/i2c_eeprom_demo.rst +++ b/docs/development_guide/source/samples/basic samples/i2c/i2c_eeprom_demo.rst @@ -25,7 +25,7 @@ I2C - AT24CXX 读写 #define BSP_I2C_CLOCK_SOURCE ROOT_CLOCK_SOURCE_BCLK #define BSP_I2C_CLOCK_DIV 0 -- 配置 ``I2C`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` +- 配置 ``I2C`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` .. code-block:: C :linenos: @@ -33,7 +33,7 @@ I2C - AT24CXX 读写 #define CONFIG_GPIO11_FUNC GPIO_FUN_I2C #define CONFIG_GPIO16_FUNC GPIO_FUN_I2C -- 配置 ``I2C`` 设备复用引脚,见 ``bsp/board/bl706_iot/peripheral_config.h`` +- 配置 ``I2C`` 设备复用引脚,见 ``bsp/board/bl706_iot/peripheral_config.h`` .. code-block:: C :linenos: @@ -97,7 +97,7 @@ I2C - AT24CXX 读写 - **CDK 编译** 打开项目中提供的工程文件:i2c_at24cxx.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** diff --git a/docs/development_guide/source/samples/basic samples/i2c/index.rst b/docs/development_guide/source/samples/basic samples/i2c/index.rst new file mode 100644 index 00000000..c5a8d721 --- /dev/null +++ b/docs/development_guide/source/samples/basic samples/i2c/index.rst @@ -0,0 +1,9 @@ +======================= +I2C 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + I2C - AT24CXX 读写 \ No newline at end of file diff --git a/docs/development_guide/source/samples/basic samples/mtimer/index.rst b/docs/development_guide/source/samples/basic samples/mtimer/index.rst new file mode 100644 index 00000000..e97a26b9 --- /dev/null +++ b/docs/development_guide/source/samples/basic samples/mtimer/index.rst @@ -0,0 +1,9 @@ +======================= +MTIMER 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + MTIMER - 系统定时器 \ No newline at end of file diff --git a/docs/development_guide/source/samples/basic samples/mtimer_demo.rst b/docs/development_guide/source/samples/basic samples/mtimer/mtimer_demo.rst similarity index 88% rename from docs/development_guide/source/samples/basic samples/mtimer_demo.rst rename to docs/development_guide/source/samples/basic samples/mtimer/mtimer_demo.rst index 9d5fb128..22e81093 100644 --- a/docs/development_guide/source/samples/basic samples/mtimer_demo.rst +++ b/docs/development_guide/source/samples/basic samples/mtimer/mtimer_demo.rst @@ -1,4 +1,4 @@ -MTIMER - 内核定时器 +MTIMER - 系统定时器 ==================== 本 demo 基于 risc-v 内核自带的一个 64 位定时器(MTIMER)编写。本 demo 可以为后面 os tick 提供参考。 @@ -11,7 +11,7 @@ MTIMER - 内核定时器 ----------------------------- - 软件代码见 ``examples/systick`` - + .. note:: ``mtimer`` 时钟默认经过分频以后为 1M,方便后面使用,减少计算时间。 .. code-block:: C @@ -34,7 +34,7 @@ MTIMER - 内核定时器 - **CDK 编译** 打开项目中提供的工程文件:systick.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** @@ -44,7 +44,7 @@ MTIMER - 内核定时器 $ cd /bl_mcu_sdk $ make BOARD=bl706_iot APP=systick - + - **烧录** 详见 :ref:`bl_dev_cube` @@ -52,4 +52,4 @@ MTIMER - 内核定时器 实验现象 ----------------------------- -``tick`` 值每秒自增 1 并通过串口打印。 \ No newline at end of file +``tick`` 值每秒自增 1 并通过串口打印。 \ No newline at end of file diff --git a/docs/development_guide/source/samples/basic samples/pwm/img/blink_breath_sch.png b/docs/development_guide/source/samples/basic samples/pwm/img/blink_breath_sch.png new file mode 100644 index 00000000..25786009 Binary files /dev/null and b/docs/development_guide/source/samples/basic samples/pwm/img/blink_breath_sch.png differ diff --git a/docs/development_guide/source/samples/basic samples/img/pwm_demo.gif b/docs/development_guide/source/samples/basic samples/pwm/img/pwm_demo.gif similarity index 100% rename from docs/development_guide/source/samples/basic samples/img/pwm_demo.gif rename to docs/development_guide/source/samples/basic samples/pwm/img/pwm_demo.gif diff --git a/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor.gif b/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor.gif new file mode 100644 index 00000000..09a0cee7 Binary files /dev/null and b/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor.gif differ diff --git a/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor.png b/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor.png new file mode 100644 index 00000000..5d8faec1 Binary files /dev/null and b/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor.png differ diff --git a/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor1.png b/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor1.png new file mode 100644 index 00000000..3180f0b6 Binary files /dev/null and b/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor1.png differ diff --git a/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor2.png b/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor2.png new file mode 100644 index 00000000..775d5da5 Binary files /dev/null and b/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor2.png differ diff --git a/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor3.png b/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor3.png new file mode 100644 index 00000000..a2b8d8d2 Binary files /dev/null and b/docs/development_guide/source/samples/basic samples/pwm/img/pwm_step_motor3.png differ diff --git a/docs/development_guide/source/samples/basic samples/pwm/img/step_motor.png b/docs/development_guide/source/samples/basic samples/pwm/img/step_motor.png new file mode 100644 index 00000000..8281cf8c Binary files /dev/null and b/docs/development_guide/source/samples/basic samples/pwm/img/step_motor.png differ diff --git a/docs/development_guide/source/samples/basic samples/pwm/img/step_motor_info.png b/docs/development_guide/source/samples/basic samples/pwm/img/step_motor_info.png new file mode 100644 index 00000000..ce561ca6 Binary files /dev/null and b/docs/development_guide/source/samples/basic samples/pwm/img/step_motor_info.png differ diff --git a/docs/development_guide/source/samples/basic samples/pwm/img/uln2003.png b/docs/development_guide/source/samples/basic samples/pwm/img/uln2003.png new file mode 100644 index 00000000..7ef6a395 Binary files /dev/null and b/docs/development_guide/source/samples/basic samples/pwm/img/uln2003.png differ diff --git a/docs/development_guide/source/samples/basic samples/pwm/index.rst b/docs/development_guide/source/samples/basic samples/pwm/index.rst new file mode 100644 index 00000000..3b66b54f --- /dev/null +++ b/docs/development_guide/source/samples/basic samples/pwm/index.rst @@ -0,0 +1,10 @@ +======================= +PWM 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + PWM - 呼吸灯 + PWM - 驱动步进电机 \ No newline at end of file diff --git a/docs/development_guide/build/html/_sources/samples/basic samples/breath_pwm_demo.rst.txt b/docs/development_guide/source/samples/basic samples/pwm/pwm_breath_demo.rst similarity index 62% rename from docs/development_guide/build/html/_sources/samples/basic samples/breath_pwm_demo.rst.txt rename to docs/development_guide/source/samples/basic samples/pwm/pwm_breath_demo.rst index b91ca37f..6ad05a0c 100644 --- a/docs/development_guide/build/html/_sources/samples/basic samples/breath_pwm_demo.rst.txt +++ b/docs/development_guide/source/samples/basic samples/pwm/pwm_breath_demo.rst @@ -1,7 +1,7 @@ PWM - 呼吸灯 ==================== - 本demo基于PWM外设轮询模式编写。 + 本 demo 基于 PWM 外设轮询模式编写。 硬件连接 ----------------------------- @@ -22,12 +22,20 @@ PWM - 呼吸灯 - 软件代码见 ``examples/pwm/pwm_breath_led`` +.. code-block:: C + :linenos: + + #define BSP_PWM_CLOCK_SOURCE ROOT_CLOCK_SOURCE_XCLK + #define BSP_PWM_CLOCK_DIV 1 + +- 配置 ``PWM`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` + .. code-block:: C :linenos: #define CONFIG_GPIO22_FUNC GPIO_FUN_PWM -- 配置 ``PWM`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` +- 配置 ``PWM`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` .. code-block:: C :linenos: @@ -51,12 +59,14 @@ PWM - 呼吸灯 .. code-block:: C :linenos: - pwm_register(PWM_CH2_INDEX, "led_breath", DEVICE_OFLAG_RDWR); + pwm_register(PWM_CH2_INDEX, "led_breath", DEVICE_OFLAG_RDWR); struct device *led_breath = device_find("led_breath"); - if (led_breath) - { + if (led_breath) { + PWM_DEV(led_breath)->period = 32; //frequence = 32M/1/32 = 1Mhz + PWM_DEV(led_breath)->threshold_low = 16; + PWM_DEV(led_breath)->threshold_high = 32; device_open(led_breath, DEVICE_OFLAG_STREAM_TX); pwm_channel_start(led_breath); } @@ -64,19 +74,23 @@ PWM - 呼吸灯 - 首先调用 ``pwm_register`` 函数注册 ``PWM`` 设备的一个通道,当前注册 ``PWM_CH2`` - 然后通过 ``find`` 函数找到设备对应的句柄,保存于 ``led_breath`` 句柄中 +- 设置 ``PWM_CH2`` 的频率为 1Mhz,占空比为50% - 使用 ``device_open`` 以轮询模式来打开 ``led_breath`` 设备 .. code-block:: C :linenos: - pwm_config_t pwm_cfg = { - 1000000, - 0, - }; - - device_control(led_breath, DEVICE_CTRL_CONFIG, &pwm_cfg); + for (pwm_cfg.threshold_high = 0; pwm_cfg.threshold_high <= 32; pwm_cfg.threshold_high++) { + device_control(led_breath, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg); + bflb_platform_delay_ms(50); + } -- 使用 ``device_contorl`` 函数,配合 ``DEVICE_CTRL_CONFIG`` 指令,可以修改当前 PWM 通道的频率和占空比。 + for (pwm_cfg.threshold_high = 32; 0 <= pwm_cfg.threshold_high && pwm_cfg.threshold_high <= 32; pwm_cfg.threshold_high--) { + device_control(led_breath, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg); + bflb_platform_delay_ms(50); + } + +- 使用 ``device_contorl`` 函数,配合 ``DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG`` 指令,可以修改当前 PWM 通道的占空比。 编译和烧录 ----------------------------- @@ -84,7 +98,7 @@ PWM - 呼吸灯 - **CDK 编译** 打开项目中提供的工程文件:pwm_breath_led.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** @@ -104,7 +118,7 @@ PWM - 呼吸灯 ----------------------------- -.. figure:: img/pwm_demo.gif +.. figure:: img/pwm_demo.gif :alt: pwm breath led! diff --git a/docs/development_guide/source/samples/basic samples/pwm/pwm_step_motor.rst b/docs/development_guide/source/samples/basic samples/pwm/pwm_step_motor.rst new file mode 100644 index 00000000..356ce0ba --- /dev/null +++ b/docs/development_guide/source/samples/basic samples/pwm/pwm_step_motor.rst @@ -0,0 +1,281 @@ +PWM - 驱动步进电机 +==================== + +步进电机是一种将电脉冲转化为角位移的执行机构。当步进驱动器接收到一个脉冲信号,它就驱动步进电机按设定的方向转动一个固定的角度(及步进角)。可以通过控制脉冲个来控制角位移量,从而达到准确定位的目的;同时可以通过控制脉冲频率来控制电机转动的速度和加速度,从而达到调速的目的。 + +本 demo 采用步进电机 28BYJ48 型四相八拍电机,使用 ULN2003 芯片驱动,电压为 DC5V—DC12V。当对步进电机施加一系列连续不断的控制脉冲时,它可以连续不断地转动。每一个脉冲信号对应步进电机的某一相或两相绕组的通电状态改变一次,也就对应转子转过一定的角度(一个步距角)。当通电状态的改变完成一个循环时,转子转过一个齿距。 + +.. figure:: img/step_motor.png + :alt: + + 28BYJ48 + +.. figure:: img/uln2003.png + :alt: + + ULN2003 + +这个步进电机内部有个真正的步进马达转子,每一个脉冲能使这个真正的转子转动5.625°,看下图的数据表格中的减速比是1:64,意思是这个真正的步进马达转子转动64周才能让输出轴转动1周,因此下图的表格中步距角度才写的是5.625°/64,表明的意思是一个脉冲可以让输出轴转动5.625°/64的角度。所以要让马达转一周(360°), 则需要360/5.625*64=4096个脉冲。 +脉冲(或拍)的数量决定转动的角度,单位时间内脉冲(或拍)的数量决定转动的速度 + +.. figure:: img/step_motor_info.png + :alt: + +四相步进电机可以在不同的通电方式下运行,常见的通电方式有如下三种: + +- 一相励磁:单(单相绕组通电)四拍(A+,B+,A-,B-......) + +.. figure:: img/pwm_step_motor1.png + :alt: + +- 二相励磁:双(双相绕组通电)四拍(A+B+,B+A-,A-B-,B-A+......) + +.. figure:: img/pwm_step_motor2.png + :alt: + +- 一二相励磁:八拍(A+B+,B+,B+A-,A-,A-B-,B-,B-A+,A+......) + +.. figure:: img/pwm_step_motor3.png + :alt: + + +硬件连接 +----------------------------- + +本 demo 基于BL706_IOT开发板,连接方式如下 + +:: + + GPIO function GPIO pin + ---------------------------------- + PWM_CH0 <--> GPIO10 + PWM_CH1 <--> GPIO11 + PWM_CH2 <--> GPIO12 + PWM_CH3 <--> GPIO3 + +.. figure:: img/pwm_step_motor.png + :alt: + + 参考电路 + +软件实现 +----------------------------- + +- 软件代码见 ``examples/pwm/pwm_step_motor`` + +.. code-block:: C + :linenos: + + #define BSP_PWM_CLOCK_SOURCE ROOT_CLOCK_SOURCE_RC_32K + #define BSP_PWM_CLOCK_DIV 32 + +- 配置 ``PWM`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` + +.. code-block:: C + :linenos: + + #define CONFIG_GPIO3_FUNC GPIO_FUN_PWM + #define CONFIG_GPIO10_FUNC GPIO_FUN_PWM + #define CONFIG_GPIO11_FUNC GPIO_FUN_PWM + #define CONFIG_GPIO12_FUNC GPIO_FUN_PWM + +- 配置 ``PWM`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` + +.. code-block:: C + :linenos: + + #define BSP_USING_PWM_CH0 + #define BSP_USING_PWM_CH1 + #define BSP_USING_PWM_CH2 + #define BSP_USING_PWM_CH3 + + #if defined(BSP_USING_PWM_CH0) + #ifndef PWM_CH0_CONFIG + #define PWM_CH0_CONFIG \ + { \ + .ch = 0, \ + .polarity_invert_mode = DISABLE, \ + .period = 0, \ + .threshold_low = 0, \ + .threshold_high = 0, \ + .it_pulse_count = 0, \ + } + #endif + #endif + + #if defined(BSP_USING_PWM_CH1) + #ifndef PWM_CH1_CONFIG + #define PWM_CH1_CONFIG \ + { \ + .ch = 1, \ + .polarity_invert_mode = DISABLE, \ + .period = 0, \ + .threshold_low = 0, \ + .threshold_high = 0, \ + .it_pulse_count = 0, \ + } + #endif + #endif + + #if defined(BSP_USING_PWM_CH2) + #ifndef PWM_CH2_CONFIG + #define PWM_CH2_CONFIG \ + { \ + .ch = 2, \ + .polarity_invert_mode = DISABLE, \ + .period = 0, \ + .threshold_low = 0, \ + .threshold_high = 0, \ + .it_pulse_count = 0, \ + } + #endif + #endif + + #if defined(BSP_USING_PWM_CH3) + #ifndef PWM_CH3_CONFIG + #define PWM_CH3_CONFIG \ + { \ + .ch = 3, \ + .polarity_invert_mode = DISABLE, \ + .period = 0, \ + .threshold_low = 0, \ + .threshold_high = 0, \ + .it_pulse_count = 0, \ + } + #endif + #endif + + +- 使能 ``BSP_USING_PWM_CH0``, ``BSP_USING_PWM_CH1`` , ``BSP_USING_PWM_CH2``, ``BSP_USING_PWM_CH3`` 并配置 ``PWM`` 设备配置,见 ``bsp/board/bl706_iot/peripheral_config.h`` + +.. code-block:: C + :linenos: + + pwm_register(PWM_CH0_INDEX, "motor_ch0", DEVICE_OFLAG_RDWR); + pwm_register(PWM_CH1_INDEX, "motor_ch1", DEVICE_OFLAG_RDWR); + pwm_register(PWM_CH2_INDEX, "motor_ch2", DEVICE_OFLAG_RDWR); + pwm_register(PWM_CH3_INDEX, "motor_ch3", DEVICE_OFLAG_RDWR); + + motor_ch0 = device_find("motor_ch0"); + motor_ch1 = device_find("motor_ch1"); + motor_ch2 = device_find("motor_ch2"); + motor_ch3 = device_find("motor_ch3"); + + if (motor_ch0) { + PWM_DEV(motor_ch0)->period = 8; //frequence = 32K/160/8 = 25hz + PWM_DEV(motor_ch0)->threshold_low = 2; + PWM_DEV(motor_ch0)->threshold_high = 7; + PWM_DEV(motor_ch0)->polarity_invert_mode = ENABLE; + device_open(motor_ch0, DEVICE_OFLAG_STREAM_TX); + } + if (motor_ch1) { + PWM_DEV(motor_ch1)->period = 8; //frequence = 32K/160/8 = 25hz + PWM_DEV(motor_ch1)->threshold_low = 1; + PWM_DEV(motor_ch1)->threshold_high = 4; + device_open(motor_ch1, DEVICE_OFLAG_STREAM_TX); + } + if (motor_ch2) { + PWM_DEV(motor_ch2)->period = 8; //frequence = 32K/160/8 = 25hz + PWM_DEV(motor_ch2)->threshold_low = 3; + PWM_DEV(motor_ch2)->threshold_high = 6; + device_open(motor_ch2, DEVICE_OFLAG_STREAM_TX); + } + if (motor_ch3) { + PWM_DEV(motor_ch3)->period = 8; //frequence = 32K/160/8 = 25hz + PWM_DEV(motor_ch3)->threshold_low = 5; + PWM_DEV(motor_ch3)->threshold_high = 8; + device_open(motor_ch3, DEVICE_OFLAG_STREAM_TX); + } + pwm_channel_start(motor_ch0); + pwm_channel_start(motor_ch1); + pwm_channel_start(motor_ch2); + pwm_channel_start(motor_ch3); + + +- 首先调用 ``pwm_register`` 函数注册 ``PWM`` 设备的一个通道,当前注册 PWM 通道0/1/2/3 +- 然后通过 ``find`` 函数找到设备对应的句柄,保存于4个句柄中 +- 设置 4个通道 的频率为 125hz,占空比为37.5% +- 使用 ``device_open`` 以轮询模式来打开 4个通道 + +.. code-block:: C + :linenos: + + enum motor_dir_type { + CW, + CCW, + STOP + }; + + void motor_set_dir(enum motor_dir_type dir) + { + pwm_dutycycle_config_t pwm_cfg[4]; + + if (dir == CW) { + pwm_cfg[0].threshold_low = 2; + pwm_cfg[0].threshold_high = 7; + pwm_cfg[1].threshold_low = 1; + pwm_cfg[1].threshold_high = 4; + pwm_cfg[2].threshold_low = 3; + pwm_cfg[2].threshold_high = 6; + pwm_cfg[3].threshold_low = 5; + pwm_cfg[3].threshold_high = 8; + } + + else if (dir == CCW) { + pwm_cfg[0].threshold_low = 2; + pwm_cfg[0].threshold_high = 7; + pwm_cfg[1].threshold_low = 5; + pwm_cfg[1].threshold_high = 8; + pwm_cfg[2].threshold_low = 3; + pwm_cfg[2].threshold_high = 6; + pwm_cfg[3].threshold_low = 1; + pwm_cfg[3].threshold_high = 4; + } else if (dir == STOP) { + pwm_cfg[0].threshold_low = 0; + pwm_cfg[0].threshold_high = 0; + pwm_cfg[1].threshold_low = 0; + pwm_cfg[1].threshold_high = 0; + pwm_cfg[2].threshold_low = 0; + pwm_cfg[2].threshold_high = 0; + pwm_cfg[3].threshold_low = 0; + pwm_cfg[3].threshold_high = 0; + } + device_control(motor_ch0, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg[0]); + device_control(motor_ch1, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg[1]); + device_control(motor_ch2, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg[2]); + device_control(motor_ch3, DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG, &pwm_cfg[3]); + } + +- 使用 ``device_contorl`` 函数,配合 ``DEIVCE_CTRL_PWM_DUTYCYCLE_CONFIG`` 指令,修改4个 PWM 通道的的高低阈值。 + +.. note:: 该函数的功能主要用于切换步进电机的方向 + +编译和烧录 +----------------------------- + +- **CDK 编译** + + 打开项目中提供的工程文件:pwm_step_motor.cdkproj + + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 + +- **命令行编译** + +.. code-block:: bash + :linenos: + + $ cd /bl_mcu_sdk + $ make BOARD=bl706_iot APP=pwm_step_motor + +- **烧录** + + 详见 :ref:`bl_dev_cube` + + +实验现象 +----------------------------- + +.. figure:: img/pwm_step_motor.gif + :alt: + + diff --git a/docs/development_guide/source/samples/basic samples/img/spi_lcd.png b/docs/development_guide/source/samples/basic samples/spi/img/spi_lcd.png similarity index 100% rename from docs/development_guide/source/samples/basic samples/img/spi_lcd.png rename to docs/development_guide/source/samples/basic samples/spi/img/spi_lcd.png diff --git a/docs/development_guide/source/samples/basic samples/spi/index.rst b/docs/development_guide/source/samples/basic samples/spi/index.rst new file mode 100644 index 00000000..4645a2ab --- /dev/null +++ b/docs/development_guide/source/samples/basic samples/spi/index.rst @@ -0,0 +1,9 @@ +======================= +SPI 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + SPI - TFT LCD 显示 \ No newline at end of file diff --git a/docs/development_guide/source/samples/basic samples/spi_lcd_demo.rst b/docs/development_guide/source/samples/basic samples/spi/spi_lcd_demo.rst similarity index 93% rename from docs/development_guide/source/samples/basic samples/spi_lcd_demo.rst rename to docs/development_guide/source/samples/basic samples/spi/spi_lcd_demo.rst index ec8a487d..c2ebe373 100644 --- a/docs/development_guide/source/samples/basic samples/spi_lcd_demo.rst +++ b/docs/development_guide/source/samples/basic samples/spi/spi_lcd_demo.rst @@ -28,7 +28,7 @@ SPI - TFT LCD 显示 #define BSP_SPI_CLOCK_SOURCE ROOT_CLOCK_SOURCE_BCLK #define BSP_SPI_CLOCK_DIV 0 -- 配置 ``SPI`` 设备时钟源,见 ``bsp/board/bl706_avb/clock_config.h`` +- 配置 ``SPI`` 设备时钟源,见 ``bsp/board/bl706_avb/clock_config.h`` .. code-block:: C :linenos: @@ -37,7 +37,7 @@ SPI - TFT LCD 显示 #define CONFIG_GPIO20_FUNC GPIO_FUN_SPI #define CONFIG_GPIO21_FUNC GPIO_FUN_SPI -- 配置 ``SPI`` 设备复用引脚,见 ``bsp/board/bl706_avb/pinmux_config.h`` +- 配置 ``SPI`` 设备复用引脚,见 ``bsp/board/bl706_avb/pinmux_config.h`` .. note:: ``bsp/board/bl706_avb/pinmux_config.h`` 当前给所有的示例demo使用,所以,需要先选定 ``PINMUX_SELECT`` 为 ``PINMUX_LVGL``,开启其中一个 demo @@ -89,7 +89,7 @@ SPI - TFT LCD 显示 } - 配置 ``LCD_CS`` 和 ``LCD_DC`` 引脚为输出模式并拉高 -- 调用 ``spi_register`` 函数注册 ``SPI`` 设备,当前注册 ``SPI0`` +- 调用 ``spi_register`` 函数注册 ``SPI`` 设备,当前注册 ``SPI0`` - 然后通过 ``find`` 函数找到设备对应的句柄,保存于 ``spi0`` 句柄中 - 最后使用 ``device_open`` 以轮询发送模式来打开 ``spi0`` 设备 @@ -128,7 +128,7 @@ SPI - TFT LCD 显示 - **CDK 编译** 打开项目中提供的工程文件:spi_lcd.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译** @@ -146,7 +146,7 @@ SPI - TFT LCD 显示 实验现象 ----------------------------- -.. figure:: img/spi_lcd.png +.. figure:: img/spi_lcd.png :alt: spi display! diff --git a/docs/development_guide/source/samples/basic samples/uart/index.rst b/docs/development_guide/source/samples/basic samples/uart/index.rst new file mode 100644 index 00000000..6f4e10e8 --- /dev/null +++ b/docs/development_guide/source/samples/basic samples/uart/index.rst @@ -0,0 +1,9 @@ +======================= +UART 示例 +======================= + + +.. toctree:: + :maxdepth: 1 + + UART - 数据自收发 \ No newline at end of file diff --git a/docs/development_guide/source/samples/basic samples/uart_loopback_demo.rst b/docs/development_guide/source/samples/basic samples/uart/uart_loopback_demo.rst similarity index 86% rename from docs/development_guide/source/samples/basic samples/uart_loopback_demo.rst rename to docs/development_guide/source/samples/basic samples/uart/uart_loopback_demo.rst index b50dd86c..dc31158b 100644 --- a/docs/development_guide/source/samples/basic samples/uart_loopback_demo.rst +++ b/docs/development_guide/source/samples/basic samples/uart/uart_loopback_demo.rst @@ -26,7 +26,7 @@ UART - 数据自收发 #define BSP_UART_CLOCK_SOURCE ROOT_CLOCK_SOURCE_PLL_96M #define BSP_UART_CLOCK_DIV 0 -- 配置 ``UART`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` +- 配置 ``UART`` 设备时钟源,见 ``bsp/board/bl706_iot/clock_config.h`` .. code-block:: C :linenos: @@ -34,7 +34,7 @@ UART - 数据自收发 #define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX #define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX -- 配置 ``UART`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` +- 配置 ``UART`` 设备复用引脚,见 ``bsp/board/bl706_iot/pinmux_config.h`` .. code-block:: C :linenos: @@ -73,13 +73,13 @@ UART - 数据自收发 if (uart) { device_open(uart, DEVICE_OFLAG_STREAM_TX | DEVICE_OFLAG_INT_RX); - device_set_callback(uart, uart_iqr_callback); - device_control(uart, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT)); + device_set_callback(uart, NULL); + device_control(uart, DEVICE_CTRL_CLR_INT, (void *)(UART_RX_FIFO_IT)); } - 首先调用 ``uart_register`` 函数注册 ``UART`` 设备,当前注册 ``UART0`` - 然后通过 ``find`` 函数找到设备对应的句柄,保存于 ``uart`` 句柄中 -- 最后使用 ``device_open`` 以轮询发送和中断接收来打开 ``uart`` 设备,调用 ``device_set_callback`` 注册一个 ``UART0`` 中断回调函数,调用 ``device_control`` 开启 ``UART RX FIFO`` 中断 +- 最后使用 ``device_open`` 以轮询发送和中断接收来打开 ``uart`` 设备,默认关闭中断并且不注册接收中断回调函数 .. code-block:: C :linenos: @@ -90,7 +90,7 @@ UART - 数据自收发 device_control(uart, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT|UART_RTO_IT)); } -- 通过 ``device_set_callback`` 函数,注册用户指定的中断服务函数。通过 ``device_control`` 函数打开 ``RX FIFO`` 和 ``RTO`` 中断 +- 通过 ``device_set_callback`` 函数,注册用户指定的``UART0`` 接收中断服务函数。通过 ``device_control`` 函数打开 ``RX_FIFO`` 和 ``RTO`` 中断 .. code-block:: C :linenos: @@ -107,9 +107,9 @@ UART - 数据自收发 } } - + - 此函数是示例的中断服务函数,作用是将接受到的数据原封不动的发送出去。 - + - ``state`` 会返回 ``UART`` 设备的中断类型 - ``args`` 包含了返回数据指针 - ``size`` 包含返回数据的长度 @@ -124,7 +124,7 @@ UART - 数据自收发 - **CDK 编译** 打开项目中提供的工程文件:uart_echo.cdkproj - + 参照 :ref:`windows_cdk_quick_start` 的步骤编译下载即可 - **命令行编译**