[feat][pmu] add bl702 hbn & pds case

This commit is contained in:
jzlv 2023-09-12 15:32:04 +08:00
parent babac132ca
commit dc1c239710
29 changed files with 1782 additions and 17 deletions

View File

@ -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)

View 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>&copy; 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__ */

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,6 @@ CHIP ?= bl616
BOARD ?= bl616dk
CROSS_COMPILE ?= riscv64-unknown-elf-
# add custom cmake definition
#cmake_definition+=-Dxxx=sss

View File

@ -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) {

View File

@ -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

View File

@ -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) {

View File

@ -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

View File

@ -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) {

View File

@ -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

View File

@ -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) {
}

View 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)

View 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

View 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
```

View 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

View 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) {
}
}

View File

View 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)

View 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

View 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
```

View 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

View 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
}
}

View 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)

View 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

View 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
```

View 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

View 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
}
}

View File