mirror of
https://github.com/bouffalolab/bouffalo_sdk.git
synced 2025-05-08 19:07:22 +08:00
[feat][pmu] add bl702 hbn & pds case
This commit is contained in:
parent
babac132ca
commit
dc1c239710
@ -18,6 +18,7 @@ sdk_library_add_sources(src/bl702_glb.c)
|
||||
sdk_library_add_sources(src/bl702_hbn.c)
|
||||
sdk_library_add_sources(src/bl702_l1c.c)
|
||||
sdk_library_add_sources(src/bl702_pds.c)
|
||||
sdk_library_add_sources(src/bl702_pm.c)
|
||||
|
||||
sdk_library_add_sources(src/bl702_sflash_ext.c)
|
||||
sdk_library_add_sources(src/bl702_xip_sflash_ext.c)
|
||||
|
93
drivers/soc/bl702/std/include/bl702_pm.h
Normal file
93
drivers/soc/bl702/std/include/bl702_pm.h
Normal file
@ -0,0 +1,93 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file bl702_pm.h
|
||||
* @version V1.0
|
||||
* @date
|
||||
* @brief This file is the standard driver header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2020 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __BL702_PM_H__
|
||||
#define __BL702_PM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
enum pm_pds_sleep_level {
|
||||
PM_PDS_LEVEL_0,
|
||||
PM_PDS_LEVEL_1,
|
||||
PM_PDS_LEVEL_2,
|
||||
PM_PDS_LEVEL_3,
|
||||
PM_PDS_LEVEL_4, /*do not recommend to use*/
|
||||
PM_PDS_LEVEL_5, /*do not recommend to use*/
|
||||
PM_PDS_LEVEL_6, /*do not recommend to use*/
|
||||
PM_PDS_LEVEL_7, /*do not recommend to use*/
|
||||
PM_PDS_LEVEL_31 = 31,
|
||||
};
|
||||
|
||||
enum pm_hbn_sleep_level {
|
||||
PM_HBN_LEVEL_0,
|
||||
PM_HBN_LEVEL_1,
|
||||
PM_HBN_LEVEL_2,
|
||||
};
|
||||
|
||||
enum pm_event_type {
|
||||
PM_HBN_WAKEUP_EVENT_NONE,
|
||||
PM_HBN_GPIO9_WAKEUP_EVENT,
|
||||
PM_HBN_GPIO10_WAKEUP_EVENT,
|
||||
PM_HBN_GPIO11_WAKEUP_EVENT,
|
||||
PM_HBN_GPIO12_WAKEUP_EVENT,
|
||||
PM_HBN_RTC_WAKEUP_EVENT,
|
||||
PM_HBN_BOR_WAKEUP_EVENT,
|
||||
PM_HBN_ACOMP0_WAKEUP_EVENT,
|
||||
PM_HBN_ACOMP1_WAKEUP_EVENT,
|
||||
};
|
||||
|
||||
void pm_pds_mode_enter(enum pm_pds_sleep_level pds_level, uint32_t sleep_time);
|
||||
void pm_hbn_mode_enter(enum pm_hbn_sleep_level hbn_level, uint32_t sleep_time);
|
||||
|
||||
void pm_pds_mask_all_wakeup_src(void);
|
||||
void pm_hbn_mask_all_wakeup_src(void);
|
||||
void pm_set_pds_wakeup_io(uint8_t pin, uint8_t trig_mode, uint8_t pupd);
|
||||
void pm_set_hbn_wakeup_io(uint8_t pin, uint8_t trig_mode, uint8_t pupd);
|
||||
void pm_pds_irq_register(void);
|
||||
void pm_hbn_out0_irq_register(void);
|
||||
void pm_hbn_out1_irq_register(void);
|
||||
void pm_set_wakeup_callback(void (*wakeup_callback)(void));
|
||||
|
||||
void pm_bor_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BL702_PM_H__ */
|
1434
drivers/soc/bl702/std/src/bl702_pm.c
Normal file
1434
drivers/soc/bl702/std/src/bl702_pm.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,6 @@ CHIP ?= bl616
|
||||
BOARD ?= bl616dk
|
||||
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||
|
||||
|
||||
# add custom cmake definition
|
||||
#cmake_definition+=-Dxxx=sss
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "bflb_mtimer.h"
|
||||
#include "board.h"
|
||||
#include "log.h"
|
||||
#include "bl616_common.h"
|
||||
#include "bl616_glb.h"
|
||||
#include "bl616_pds.h"
|
||||
#include "bl616_hbn.h"
|
||||
@ -32,7 +31,7 @@ int main(void)
|
||||
printf("enter hbn mode\r\n");
|
||||
bflb_mtimer_delay_ms(100);
|
||||
|
||||
/* sleep time must set zeor to avoid using rtc */
|
||||
/* sleep time must set zero to avoid using rtc */
|
||||
pm_hbn_mode_enter(PM_HBN_LEVEL_0, 0);
|
||||
|
||||
while (1) {
|
||||
|
@ -7,10 +7,6 @@ CHIP ?= bl616
|
||||
BOARD ?= bl616dk
|
||||
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||
|
||||
# cmake_definition+=-DPM_PDS_GPIO_KEEP_EN=1
|
||||
sdk_add_compile_definitions(PM_PDS_GPIO_KEEP_EN=1)
|
||||
|
||||
|
||||
# add custom cmake definition
|
||||
#cmake_definition+=-Dxxx=sss
|
||||
|
||||
|
@ -10,7 +10,7 @@ int main(void)
|
||||
printf("enter hbn mode\r\n");
|
||||
bflb_mtimer_delay_ms(100);
|
||||
|
||||
/* Wake up every 1 seconds by hb0 */
|
||||
/* Wake up every 1 seconds by hbn0 */
|
||||
pm_hbn_mode_enter(PM_HBN_LEVEL_0, 32768*1);
|
||||
|
||||
while (1) {
|
||||
|
@ -7,10 +7,6 @@ CHIP ?= bl616
|
||||
BOARD ?= bl616dk
|
||||
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||
|
||||
# cmake_definition+=-DPM_PDS_GPIO_KEEP_EN=1
|
||||
sdk_add_compile_definitions(PM_PDS_GPIO_KEEP_EN=1)
|
||||
|
||||
|
||||
# add custom cmake definition
|
||||
#cmake_definition+=-Dxxx=sss
|
||||
|
||||
|
@ -130,6 +130,7 @@ int main(void)
|
||||
bl_lp_set_pds_io(0,PDS_GPIO_INT_SYNC_HIGH_LEVEL,BL_LP_IO_RES_PULL_DOWN);
|
||||
bl_lp_set_aon_io(19,HBN_GPIO_INT_TRIGGER_SYNC_HIGH_LEVEL,BL_LP_IO_RES_PULL_DOWN);
|
||||
|
||||
/* sleep time must set zero to avoid using rtc */
|
||||
pm_pds_mode_enter(PM_PDS_LEVEL_15, 0);
|
||||
|
||||
while (1) {
|
||||
|
@ -7,10 +7,6 @@ CHIP ?= bl616
|
||||
BOARD ?= bl616dk
|
||||
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||
|
||||
# cmake_definition+=-DPM_PDS_GPIO_KEEP_EN=1
|
||||
sdk_add_compile_definitions(PM_PDS_GPIO_KEEP_EN=1)
|
||||
|
||||
|
||||
# add custom cmake definition
|
||||
#cmake_definition+=-Dxxx=sss
|
||||
|
||||
|
@ -25,7 +25,7 @@ int main(void)
|
||||
bflb_mtimer_delay_ms(100);
|
||||
|
||||
/* Wake up every 1 seconds by pds15 */
|
||||
pm_pds_mode_enter(PM_PDS_LEVEL_15, 32768*1);
|
||||
pm_pds_mode_enter(PM_PDS_LEVEL_15, 32768 * 1);
|
||||
|
||||
while (1) {
|
||||
}
|
||||
|
9
examples/pmu/bl702/hbn_rtc/CMakeLists.txt
Normal file
9
examples/pmu/bl702/hbn_rtc/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
include(proj.conf)
|
||||
|
||||
find_package(bouffalo_sdk REQUIRED HINTS $ENV{BL_SDK_BASE})
|
||||
|
||||
sdk_set_main_file(main.c)
|
||||
|
||||
project(hbn_rtc)
|
13
examples/pmu/bl702/hbn_rtc/Makefile
Normal file
13
examples/pmu/bl702/hbn_rtc/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
SDK_DEMO_PATH ?= .
|
||||
BL_SDK_BASE ?= $(SDK_DEMO_PATH)/../../../..
|
||||
|
||||
export BL_SDK_BASE
|
||||
|
||||
CHIP ?= bl702
|
||||
BOARD ?= bl702dk
|
||||
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||
|
||||
# add custom cmake definition
|
||||
#cmake_definition+=-Dxxx=sss
|
||||
|
||||
include $(BL_SDK_BASE)/project.build
|
22
examples/pmu/bl702/hbn_rtc/README.md
Normal file
22
examples/pmu/bl702/hbn_rtc/README.md
Normal file
@ -0,0 +1,22 @@
|
||||
# hbn_rtc
|
||||
|
||||
|
||||
## Support CHIP
|
||||
|
||||
| CHIP | Remark |
|
||||
|:----------------:|:------:|
|
||||
|BL702/BL702/BL706 | |
|
||||
|
||||
## Compile
|
||||
|
||||
- BL702/BL702/BL706
|
||||
|
||||
```
|
||||
make CHIP=bl702 BOARD=bl702dk
|
||||
```
|
||||
|
||||
## Flash
|
||||
|
||||
```
|
||||
make flash CHIP=chip_name COMX=xxx # xxx is your com name
|
||||
```
|
11
examples/pmu/bl702/hbn_rtc/flash_prog_cfg.ini
Normal file
11
examples/pmu/bl702/hbn_rtc/flash_prog_cfg.ini
Normal file
@ -0,0 +1,11 @@
|
||||
[cfg]
|
||||
# 0: no erase, 1:programmed section erase, 2: chip erase
|
||||
erase = 1
|
||||
# skip mode set first para is skip addr, second para is skip len, multi-segment region with ; separated
|
||||
skip_mode = 0x0, 0x0
|
||||
# 0: not use isp mode, #1: isp mode
|
||||
boot2_isp_mode = 0
|
||||
|
||||
[FW]
|
||||
filedir = ./build/build_out/hbn*_$(CHIPNAME).bin
|
||||
address = 0x000000
|
21
examples/pmu/bl702/hbn_rtc/main.c
Normal file
21
examples/pmu/bl702/hbn_rtc/main.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include "bflb_mtimer.h"
|
||||
#include "board.h"
|
||||
#include "log.h"
|
||||
#include "bl702_pm.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
board_init();
|
||||
|
||||
pm_pds_mask_all_wakeup_src();
|
||||
pm_hbn_mask_all_wakeup_src();
|
||||
|
||||
printf("enter hbn mode\r\n");
|
||||
bflb_mtimer_delay_ms(100);
|
||||
|
||||
/* Wake up every 1 seconds by hbn0 */
|
||||
pm_hbn_mode_enter(PM_HBN_LEVEL_0, 32768*1);
|
||||
|
||||
while (1) {
|
||||
}
|
||||
}
|
0
examples/pmu/bl702/hbn_rtc/proj.conf
Normal file
0
examples/pmu/bl702/hbn_rtc/proj.conf
Normal file
11
examples/pmu/bl702/pds_io_wakeup/CMakeLists.txt
Normal file
11
examples/pmu/bl702/pds_io_wakeup/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
include(proj.conf)
|
||||
|
||||
find_package(bouffalo_sdk REQUIRED HINTS $ENV{BL_SDK_BASE})
|
||||
|
||||
sdk_add_compile_definitions(-DPM_PDS_LDO_LEVEL_DEFAULT=10)
|
||||
|
||||
sdk_set_main_file(main.c)
|
||||
|
||||
project(pds_io_wakeup)
|
13
examples/pmu/bl702/pds_io_wakeup/Makefile
Normal file
13
examples/pmu/bl702/pds_io_wakeup/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
SDK_DEMO_PATH ?= .
|
||||
BL_SDK_BASE ?= $(SDK_DEMO_PATH)/../../../..
|
||||
|
||||
export BL_SDK_BASE
|
||||
|
||||
CHIP ?= bl702
|
||||
BOARD ?= bl702dk
|
||||
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||
|
||||
# add custom cmake definition
|
||||
#cmake_definition+=-Dxxx=sss
|
||||
|
||||
include $(BL_SDK_BASE)/project.build
|
22
examples/pmu/bl702/pds_io_wakeup/README.md
Normal file
22
examples/pmu/bl702/pds_io_wakeup/README.md
Normal file
@ -0,0 +1,22 @@
|
||||
# pds_io_wakeup
|
||||
|
||||
|
||||
## Support CHIP
|
||||
|
||||
| CHIP | Remark |
|
||||
|:----------------:|:------:|
|
||||
|BL702/BL702/BL706 | |
|
||||
|
||||
## Compile
|
||||
|
||||
- BL702/BL702/BL706
|
||||
|
||||
```
|
||||
make CHIP=bl702 BOARD=bl702dk
|
||||
```
|
||||
|
||||
## Flash
|
||||
|
||||
```
|
||||
make flash CHIP=chip_name COMX=xxx # xxx is your com name
|
||||
```
|
11
examples/pmu/bl702/pds_io_wakeup/flash_prog_cfg.ini
Normal file
11
examples/pmu/bl702/pds_io_wakeup/flash_prog_cfg.ini
Normal file
@ -0,0 +1,11 @@
|
||||
[cfg]
|
||||
# 0: no erase, 1:programmed section erase, 2: chip erase
|
||||
erase = 1
|
||||
# skip mode set first para is skip addr, second para is skip len, multi-segment region with ; separated
|
||||
skip_mode = 0x0, 0x0
|
||||
# 0: not use isp mode, #1: isp mode
|
||||
boot2_isp_mode = 0
|
||||
|
||||
[FW]
|
||||
filedir = ./build/build_out/pds*_$(CHIPNAME).bin
|
||||
address = 0x000000
|
33
examples/pmu/bl702/pds_io_wakeup/main.c
Normal file
33
examples/pmu/bl702/pds_io_wakeup/main.c
Normal file
@ -0,0 +1,33 @@
|
||||
#include "bflb_mtimer.h"
|
||||
#include "board.h"
|
||||
#include "log.h"
|
||||
#include "bl702_pm.h"
|
||||
#include "bl702_hbn.h"
|
||||
#include "bl702_pds.h"
|
||||
#include "bflb_gpio.h"
|
||||
|
||||
#define TEST_PDS_LEVEL_3 1
|
||||
|
||||
int main(void)
|
||||
{
|
||||
board_init();
|
||||
|
||||
pm_pds_mask_all_wakeup_src();
|
||||
pm_hbn_mask_all_wakeup_src();
|
||||
|
||||
/* gpio only support one pin from gpio0 to gpio7, and pupd does not support in bl702 */
|
||||
pm_set_pds_wakeup_io(GPIO_PIN_0, PDS_AON_GPIO_INT_TRIGGER_SYNC_LOW_LEVEL, 0);
|
||||
while (1) {
|
||||
printf("enter pds mode\r\n");
|
||||
bflb_mtimer_delay_ms(100);
|
||||
|
||||
#if TEST_PDS_LEVEL_3
|
||||
/* sleep time must set zero to avoid using rtc */
|
||||
pm_pds_mode_enter(PM_PDS_LEVEL_3, 0);
|
||||
printf("exit pds3 mode\r\n");
|
||||
#else
|
||||
/* sleep time must set zero to avoid using rtc */
|
||||
pm_pds_mode_enter(PM_PDS_LEVEL_31, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
0
examples/pmu/bl702/pds_io_wakeup/proj.conf
Normal file
0
examples/pmu/bl702/pds_io_wakeup/proj.conf
Normal file
11
examples/pmu/bl702/pds_rtc/CMakeLists.txt
Normal file
11
examples/pmu/bl702/pds_rtc/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
include(proj.conf)
|
||||
|
||||
find_package(bouffalo_sdk REQUIRED HINTS $ENV{BL_SDK_BASE})
|
||||
|
||||
sdk_add_compile_definitions(-DPM_PDS_LDO_LEVEL_DEFAULT=10)
|
||||
|
||||
sdk_set_main_file(main.c)
|
||||
|
||||
project(pds_rtc)
|
13
examples/pmu/bl702/pds_rtc/Makefile
Normal file
13
examples/pmu/bl702/pds_rtc/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
SDK_DEMO_PATH ?= .
|
||||
BL_SDK_BASE ?= $(SDK_DEMO_PATH)/../../../..
|
||||
|
||||
export BL_SDK_BASE
|
||||
|
||||
CHIP ?= bl702
|
||||
BOARD ?= bl702dk
|
||||
CROSS_COMPILE ?= riscv64-unknown-elf-
|
||||
|
||||
# add custom cmake definition
|
||||
#cmake_definition+=-Dxxx=sss
|
||||
|
||||
include $(BL_SDK_BASE)/project.build
|
22
examples/pmu/bl702/pds_rtc/README.md
Normal file
22
examples/pmu/bl702/pds_rtc/README.md
Normal file
@ -0,0 +1,22 @@
|
||||
# pds_rtc
|
||||
|
||||
|
||||
## Support CHIP
|
||||
|
||||
| CHIP | Remark |
|
||||
|:----------------:|:------:|
|
||||
|BL702/BL702/BL706 | |
|
||||
|
||||
## Compile
|
||||
|
||||
- BL702/BL702/BL706
|
||||
|
||||
```
|
||||
make CHIP=bl702 BOARD=bl702dk
|
||||
```
|
||||
|
||||
## Flash
|
||||
|
||||
```
|
||||
make flash CHIP=chip_name COMX=xxx # xxx is your com name
|
||||
```
|
11
examples/pmu/bl702/pds_rtc/flash_prog_cfg.ini
Normal file
11
examples/pmu/bl702/pds_rtc/flash_prog_cfg.ini
Normal file
@ -0,0 +1,11 @@
|
||||
[cfg]
|
||||
# 0: no erase, 1:programmed section erase, 2: chip erase
|
||||
erase = 1
|
||||
# skip mode set first para is skip addr, second para is skip len, multi-segment region with ; separated
|
||||
skip_mode = 0x0, 0x0
|
||||
# 0: not use isp mode, #1: isp mode
|
||||
boot2_isp_mode = 0
|
||||
|
||||
[FW]
|
||||
filedir = ./build/build_out/pds*_$(CHIPNAME).bin
|
||||
address = 0x000000
|
27
examples/pmu/bl702/pds_rtc/main.c
Normal file
27
examples/pmu/bl702/pds_rtc/main.c
Normal file
@ -0,0 +1,27 @@
|
||||
#include "bflb_mtimer.h"
|
||||
#include "board.h"
|
||||
#include "log.h"
|
||||
#include "bl702_pm.h"
|
||||
#include "bl702_hbn.h"
|
||||
|
||||
#define TEST_PDS_LEVEL_3 1
|
||||
|
||||
int main(void)
|
||||
{
|
||||
board_init();
|
||||
|
||||
pm_pds_mask_all_wakeup_src();
|
||||
pm_hbn_mask_all_wakeup_src();
|
||||
|
||||
while (1) {
|
||||
printf("enter pds mode\r\n");
|
||||
bflb_mtimer_delay_ms(100);
|
||||
|
||||
#if TEST_PDS_LEVEL_3
|
||||
pm_pds_mode_enter(PM_PDS_LEVEL_3, 32768 * 1);
|
||||
printf("exit pds3 mode\r\n");
|
||||
#else
|
||||
pm_pds_mode_enter(PM_PDS_LEVEL_31, 32768 * 1);
|
||||
#endif
|
||||
}
|
||||
}
|
0
examples/pmu/bl702/pds_rtc/proj.conf
Normal file
0
examples/pmu/bl702/pds_rtc/proj.conf
Normal file
Loading…
x
Reference in New Issue
Block a user