diff --git a/examples/adc/adc_int/CMakeLists.txt b/examples/adc/adc_int/CMakeLists.txt new file mode 100644 index 00000000..bfd0e557 --- /dev/null +++ b/examples/adc/adc_int/CMakeLists.txt @@ -0,0 +1,5 @@ +set(mains main.c) +generate_bin() + + + diff --git a/examples/adc/adc_int/cdk/adc_int.cdkproj b/examples/adc/adc_int/cdk/adc_int.cdkproj new file mode 100644 index 00000000..0224ba1c --- /dev/null +++ b/examples/adc/adc_int/cdk/adc_int.cdkproj @@ -0,0 +1,735 @@ + + + CPU: RV32IMAFC +Chip: bl70x +Board: bl70x_iot + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 154 + 104 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ;;; + ;;MHZ; + + glb + uart + + 1 + 1 + + 100:8;100:8;100:8;100:8; + + + + ;;; + ;;MHZ; + + glb + uart + + 1 + 1 + + 100:8;100:8;100:8;100:8; + + + + + + + + + no + 0x23000000 + 0x100000 + + + no + 0x22014000 + 0x4000 + + + no + 0x42018000 + 0x8000 + + + no + + + + + no + + + + + + + yes + 0x42020000 + 0xc000 + yes + + + no + + + yes + + + no + + + yes + + + no + + + yes + + + no + + + yes + + + rv32imafc + yes + little + no + no + no + no + + + $(ProjectName) + Executable + no + yes + no + yes + no + yes + + + + no + + + + no + + + + no + $(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --interface=openocd --firmware="$(ProjectPath)/Obj/$(ProjectName).bin" + + + + ARCH_RISCV;BFLB_USE_HAL_DRIVER;BFLB_USE_ROM_DRIVER;bl706_iot + + Optimize more (-O2) + Default (-g) + $(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc + -fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -Wignored-qualifiers -Wunused -Wundef -msmall-data-limit=4 -std=c99 + no + no + no + no + no + no + yes + no + yes + no + + + + + $(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc + + gdwarf2 + + + yes + yes + $(ProjectPath)../../../../drivers/bl702_driver/bl702_flash.ld + c + + --specs=nano.specs + no + + + + yes + OpenOCD + yes + main + + $(ProjectPath)/../../../../tools/openocd/bl70x_gdb.init + yes + Hard Reset + 23000000 + no + no + $(ProjectPath)/$(ProjectName).cdkcore + + localhost + 1025 + 0 + 2000 + 10 + 50 + yes + no + no + Normal + Hard Reset + 21000000 + Bare Metal + yes + yes + + Local + -arch riscv + + + + + yes + no + no + + + openocd-hifive + no + 4444 + no + 6666 + -f ../../../../tools/openocd/if_rv_dbg_plus.cfg -f ../../../../tools/openocd/tgt_702.cfg + + + + + Erase Sectors + bl70x_flasher.elf + yes + yes + no + Hard Reset + + no + + + + + + + + + no + 0x23000000 + 0x100000 + + + no + 0x22014000 + 0x4000 + + + no + 0x42018000 + 0x8000 + + + no + + + + + no + + + + + + + yes + 0x42020000 + 0xc000 + yes + + + no + + + yes + + + no + + + yes + + + no + + + yes + + + no + + + yes + + + rv32imafc + yes + little + no + no + no + no + + + $(ProjectName) + Executable + no + yes + no + yes + no + yes + + + + no + + + + no + + + + no + $(ProjectPath)../../../../tools/bflb_flash_tool/bflb_mcu_tool.exe --chipname=bl702 --interface=openocd --firmware="$(ProjectPath)/Obj/$(ProjectName).bin" + + + + ARCH_RISCV;BFLB_USE_HAL_DRIVER;BFLB_USE_ROM_DRIVER;bl706_iot + + Optimize more (-O2) + Default (-g) + $(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc + -fshort-enums -fno-common -fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -Wignored-qualifiers -Wunused -Wundef -msmall-data-limit=4 -std=c99 + no + no + no + no + no + no + yes + no + yes + no + + + + + $(ProjectPath);$(ProjectPath)../;$(ProjectPath)../../../../components/fatfs;$(ProjectPath)../../../../components/freertos/Source/include;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../components/usb_stack/class/audio;$(ProjectPath)../../../../components/usb_stack/class/cdc;$(ProjectPath)../../../../components/usb_stack/class/hid;$(ProjectPath)../../../../components/usb_stack/class/msc;$(ProjectPath)../../../../components/usb_stack/class/video;$(ProjectPath)../../../../components/usb_stack/class/webusb;$(ProjectPath)../../../../components/usb_stack/class/winusb;$(ProjectPath)../../../../components/usb_stack/common;$(ProjectPath)../../../../components/usb_stack/core;$(ProjectPath)../../../../bsp/board/bl702;$(ProjectPath)../../../../bsp/bsp_common/platform;$(ProjectPath)../../../../common/device;$(ProjectPath)../../../../common/list;$(ProjectPath)../../../../common/memheap;$(ProjectPath)../../../../common/misc;$(ProjectPath)../../../../common/ring_buffer;$(ProjectPath)../../../../common/soft_crc;$(ProjectPath)../../../../components/shell;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl702_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl702_driver/regs;$(ProjectPath)../../../../drivers/bl702_driver/startup;$(ProjectPath)../../../../drivers/bl702_driver/std_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/risc-v/Core/Include;$(ProjectPath)../../../../drivers/bl602_driver/startup;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/inc;$(ProjectPath)../../../../drivers/bl602_driver/hal_drv/default_config;$(ProjectPath)../../../../drivers/bl602_driver/regs;$(ProjectPath)../../../../drivers/bl602_driver/std_drv/inc + + gdwarf2 + + + yes + yes + $(ProjectPath)../../../../drivers/bl702_driver/bl702_flash.ld + c + + --specs=nano.specs + no + + + + yes + ICE + yes + main + + $(ProjectPath)/../../../../tools/openocd/bl70x_gdb.init + yes + Hard Reset + 23000000 + no + no + $(ProjectPath)/$(ProjectName).cdkcore + + localhost + 1025 + 0 + 2000 + 10 + 50 + yes + no + no + Normal + Hard Reset + 21000000 + Bare Metal + yes + yes + + Local + -arch riscv + + + + + yes + no + no + + + openocd-hifive + no + 4444 + no + 6666 + -f ../../../../tools/openocd/if_rv_dbg_plus.cfg -f ../../../../tools/openocd/tgt_702.cfg + + + + + Erase Sectors + bl702_flasher.elf + yes + yes + no + Hard Reset + + no + + + + + + diff --git a/examples/adc/adc_int/main.c b/examples/adc/adc_int/main.c new file mode 100644 index 00000000..eda5490d --- /dev/null +++ b/examples/adc/adc_int/main.c @@ -0,0 +1,77 @@ +/** + * @file main.c + * @brief + * + * Copyright (c) 2021 Bouffalolab team + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + */ +#include "hal_adc.h" +#include "hal_gpio.h" + +adc_channel_t posChList[] = { ADC_CHANNEL3 }; +adc_channel_t negChList[] = { ADC_CHANNEL_GND }; + +void adc_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state) +{ + if (state == ADC_EVENT_FIFO) { + MSG("FIFO Ready Interrupt Happend \r\n"); + adc_channel_val_t *adc_parse_val = (adc_channel_val_t *)args; + for (uint32_t i = 0; i < size; i++) { + MSG("PosId = %d NegId = %d V= %d mV ", adc_parse_val[i].posChan, adc_parse_val[i].negChan, (uint32_t)(adc_parse_val[i].volt * 1000)); + } + BL_CASE_SUCCESS; + device_control(dev, DEVICE_CTRL_CLR_INT, (void *)(ADC_FIFO_IT)); + } else { + } +} + +struct device *adc_test; + +int main(void) +{ + bflb_platform_init(0); + + adc_channel_cfg_t adc_channel_cfg; + + adc_channel_cfg.pos_channel = posChList; + adc_channel_cfg.neg_channel = negChList; + adc_channel_cfg.num = 1; + + adc_register(ADC0_INDEX, "adc"); + + adc_test = device_find("adc"); + + if (adc_test) { + device_open(adc_test, DEVICE_OFLAG_INT_RX); + device_set_callback(adc_test, adc_irq_callback); + device_control(adc_test, DEVICE_CTRL_SET_INT, (void *)(ADC_FIFO_IT)); + + if (device_control(adc_test, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg) == ERROR) { + MSG("ADC channel config error , Please check the channel corresponding to IO is initial success by board system or Channel is invaild \r\n"); + BL_CASE_FAIL; + while (1) + ; + } + MSG("adc device find success\r\n"); + } + + adc_channel_start(adc_test); + + while (1) + bflb_platform_delay_ms(100); +} \ No newline at end of file diff --git a/examples/adc/adc_int/readme.md b/examples/adc/adc_int/readme.md new file mode 100644 index 00000000..cf6317f8 --- /dev/null +++ b/examples/adc/adc_int/readme.md @@ -0,0 +1,5 @@ +```bash + +$ make APP=adc_continuous_differential BOARD=bl706_iot + +``` \ No newline at end of file