1.【需求描述】 L0 支持低功耗投票框架, 使内核与应用、驱动分离开,通过注册及投票机制控制系统的低功耗模式, 减低系统功耗,提升设备电池寿命。 2.【方案描述】 (1).提供注册机制,使驱动与内核分离 (2).提供投票机制,判断系统运行模式 (3).记录持锁设备,便于回溯 进入:系统运行进入idle任务时判断当前的功耗模式,如果上层应用未对当前功耗模式(deep和shutdown) 持锁,则系统准备进入当前模式,首先所有设备依次进入当前模式,如果有设备进入当前模式失败,则恢复 已进入当前模式的所有设备,并且功耗模式变为normal模式;设备依次进入当前功耗模式后cpu再进入当前 功耗模式。 恢复:功耗模式为deep时,需要恢复逻辑,时系统恢复运行。当有中断出发时,系统会退出低功耗模式, 恢复顺序为:首先cpu先恢复,然后设备依次恢复。 BREAKING CHANGE: 1.原调度中基于tick timer的低功耗扩展和当前的pm模块合并,删除原对外接口LOS_SchedSleepInit, 变为pm模块统一提供的LOS_PmRegistered接口. 2.原来在arch los_timer.h下提供的低功耗模式为枚举LOS_SysSleepEnum,其中OS_SYS_NORMAL_SLEEP 和OS_SYS_DEEP_SLEEP不符合对外定义,统一修改为LOS_SYS_NORMAL_SLEEP和LOS_SYS_DEEP_SLEEP, 并移至los_pm.h中. 3.VOID HalEnterSleep(LOS_SysSleepEnum sleep) 变更为UINT32 HalEnterSleep(VOID). Close #I3UDNV Signed-off-by: zhushengle <zhushengle@huawei.com> Change-Id: Id5382c42c8055ba7850895a3f575130a73e38a65
LiteOS Cortex-M
Introduction
The OpenHarmony LiteOS Cortex-M is the kernel designed for the lightweight operating system (OS) for the Internet of Things (IoT) field. It features small size, low power consumption, and high performance. In addition, it has a simple code structure, including the minimum kernel function set, kernel abstraction layer, optional components, and project directory, and is divided into the hardware-related and hardware-irrelevant layers. The hardware-related layers provide unified hardware abstraction layer (HAL) interfaces to improve hardware adaptability. The combination and classification of different compilation toolchains and chip architectures meet the requirements of the Artificial Intelligence of Things (AIoT) field for rich hardware and compilation toolchains. Figure1 shows the architecture of the OpenHarmony LiteOS Cortex-M kernel.
Figure 1 Architecture of OpenHarmony the LiteOS Cortex-M kernel

Directory Structure
The directory structure is listed as below, for the detailed directories, please refer to arch_spec.md.
/kernel/liteos_m
├── components # Optional components
│ ├── backtrace # Backtrace support
│ ├── cppsupport # C++ support
│ ├── cpup # CPU possession (CPUP)
│ ├── exchook # Exception hook
│ ├── fs # File system
│ └── net # Network support
├── kal # Kernel abstraction layer
│ ├── cmsis # CMSIS-compliant API support
│ └── posix # POSIX API support
├── kernel # Minimum function set support
│ ├── arch # Code of the kernel instruction architecture layer
│ │ ├── arm # Code of the ARM32 architecture
│ │ └── include # APIs exposed externally
│ ├── include # APIs exposed externally
│ └── src # Source code of the minimum function set of the kernel
├── targets # Board-level projects
├── utils # Common code
Constraints
Programming languages: C and C++
Currently applicable architectures: Cortex-M3, Cortex-M4, Cortex-M7, and RISC-V
Usage
LiteOS Cortex-M provides projects for three chip architectures, which are located in the targets directory. The methods of compiling and using these projects are as follows:
- Cortex-M3:
The kernel/liteos_m/targets/cortex-m3_stm32f103_simulator_keil directory is the Keil project directory created based on the STM32F103 chip architecture. You can download and install Keil development tools from the Internet. To compile the Cortex-M3 project, go to the cortex-m3_stm32f103_simulator_keil/project directory and double-click the los_demo.uvproj file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility.
- Cortex-M4:
The kernel/liteos_m/targets/cortex-m4_stm32f429ig_fire-challenger_iar directory is the IAR project directory created based on the STM32F429IG chip architecture. You can download and install IAR development tools from the Internet. To compile the Cortex-M4 project, go to the cortex-m4_stm32f429ig_fire-challenger_iar/project directory and double-click the los_demo.eww file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility.
- Cortex-M7:
The kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc directory is the Makefile project directory created based on the STM32F767ZI chip architecture. The compilation commands are as follows:
cd kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc
make clean; make
After the compilation is successful, the executable file NUCLEO-F767.hex is generated in the cortex-m7_nucleo_f767zi_gcc/build directory. Burn the file to the corresponding board using STM32 ST-LINK Utility.
Change Log
v1.0.1
- removed these KAL apis:
KalThreadGetInfo,KalDelayUs,KalTimerCreate,KalTimerStart,KalTimerChange,KalTimerStop,KalTimerDelete,KalTimerIsRunning,KalTickToMs,KalMsToTick,KalGetMemInfo - add some POSIX apis
v1.0
- first release
Repositories Involved
kernel_liteos_m