├── .gitignore
├── .vscode
├── c_cpp_properties.json
└── settings.json
├── Drivers
├── CMSIS
│ ├── Device
│ │ └── ST
│ │ │ └── STM32L0xx
│ │ │ └── Include
│ │ │ ├── stm32l051xx.h
│ │ │ ├── stm32l0xx.h
│ │ │ └── system_stm32l0xx.h
│ └── Include
│ │ ├── arm_common_tables.h
│ │ ├── arm_const_structs.h
│ │ ├── arm_math.h
│ │ ├── cmsis_armcc.h
│ │ ├── cmsis_armcc_V6.h
│ │ ├── cmsis_gcc.h
│ │ ├── core_cm0.h
│ │ ├── core_cm0plus.h
│ │ ├── core_cm3.h
│ │ ├── core_cm4.h
│ │ ├── core_cm7.h
│ │ ├── core_cmFunc.h
│ │ ├── core_cmInstr.h
│ │ ├── core_cmSimd.h
│ │ ├── core_sc000.h
│ │ └── core_sc300.h
└── STM32L0xx_HAL_Driver
│ ├── Inc
│ ├── stm32l0xx_ll_adc.h
│ ├── stm32l0xx_ll_bus.h
│ ├── stm32l0xx_ll_cortex.h
│ ├── stm32l0xx_ll_crs.h
│ ├── stm32l0xx_ll_dma.h
│ ├── stm32l0xx_ll_exti.h
│ ├── stm32l0xx_ll_gpio.h
│ ├── stm32l0xx_ll_i2c.h
│ ├── stm32l0xx_ll_lptim.h
│ ├── stm32l0xx_ll_pwr.h
│ ├── stm32l0xx_ll_rcc.h
│ ├── stm32l0xx_ll_spi.h
│ ├── stm32l0xx_ll_system.h
│ ├── stm32l0xx_ll_tim.h
│ ├── stm32l0xx_ll_usart.h
│ └── stm32l0xx_ll_utils.h
│ └── Src
│ ├── stm32l0xx_ll_adc.c
│ ├── stm32l0xx_ll_dma.c
│ ├── stm32l0xx_ll_exti.c
│ ├── stm32l0xx_ll_gpio.c
│ ├── stm32l0xx_ll_i2c.c
│ ├── stm32l0xx_ll_lptim.c
│ ├── stm32l0xx_ll_pwr.c
│ ├── stm32l0xx_ll_rcc.c
│ ├── stm32l0xx_ll_spi.c
│ ├── stm32l0xx_ll_tim.c
│ ├── stm32l0xx_ll_usart.c
│ └── stm32l0xx_ll_utils.c
├── Inc
├── adc.h
├── gpio.h
├── i2c.h
├── lptim.h
├── main.h
├── spi.h
├── stm32_assert.h
├── stm32l0xx_it.h
├── tim.h
└── usart.h
├── L051K8U6_EPD_CLOCK.ioc
├── LICENSE
├── MDK-ARM
├── DebugConfig
│ └── L051K8U6_EPD_CLOCK_STM32L051K8Ux.dbgconf
├── L051K8U6_EPD_CLOCK.uvoptx
├── L051K8U6_EPD_CLOCK.uvprojx
├── L051K8U6_EPD_CLOCK
│ └── L051K8U6_EPD_CLOCK.hex
├── RTE
│ └── _L051K8U6_EPD_CLOCK
│ │ └── RTE_Components.h
└── startup_stm32l051xx.s
├── Src
├── USER
│ ├── analog.c
│ ├── analog.h
│ ├── bkpr.c
│ ├── bkpr.h
│ ├── buzzer.c
│ ├── buzzer.h
│ ├── ds3231.c
│ ├── ds3231.h
│ ├── eeprom.c
│ ├── eeprom.h
│ ├── func.c
│ ├── func.h
│ ├── gdeh029a1.c
│ ├── gdeh029a1.h
│ ├── iic.c
│ ├── iic.h
│ ├── lowpower.c
│ ├── lowpower.h
│ ├── lunar.c
│ ├── lunar.h
│ ├── serial.c
│ ├── serial.h
│ ├── sht30.c
│ └── sht30.h
├── adc.c
├── gpio.c
├── i2c.c
├── lptim.c
├── main.c
├── spi.c
├── stm32l0xx_it.c
├── system_stm32l0xx.c
├── tim.c
└── usart.c
├── 带链接的BOM表.xls
└── 资源
├── PCB
└── AltiumDesigner
│ ├── 2.9inch_EPD_Module.zip
│ ├── MultiBoard_2.9EPD+L051.zip
│ └── STM32L051K8U6_LOWPOWER_CLOCK.zip
├── 位图
├── 12x24
│ ├── $.BMP
│ ├── &.BMP
│ └── @.BMP
├── 16x16
│ ├── 一.BMP
│ ├── 三.BMP
│ ├── 二.BMP
│ ├── 十.BMP
│ └── 度.BMP
├── 24x24
│ ├── 一.BMP
│ ├── 三.BMP
│ ├── 上箭头.BMP
│ ├── 二.BMP
│ ├── 十.BMP
│ ├── 右箭头.BMP
│ ├── 左箭头.bmp
│ ├── 温度.bmp
│ └── 百分.bmp
├── 上箭头_12x8.BMP
├── 上箭头_8x8.BMP
├── 欢迎_296x96.bmp
├── 欢迎界面.xcf
├── 电池电量低_296x128.bmp
├── 电池警告_37x24.bmp
└── 系统信息_89x128.bmp
├── 农历数据生成
├── 农历数据表生成.htm
└── 项目地址.txt
├── 字体
├── 2015Jun24-Font-Truetype.zip
└── digital_dismay.zip
├── 字模取模
├── PCtoLCD2002.zip
└── 字模转换.zip
└── 数据表
├── DIP_AAA_1023.PDF
├── DS3231.pdf
├── HINK-E029A01-0629.pdf
├── Sensirion_Humidity_Sensors_SHT3x_Datasheet_digital.pdf
├── Si2305DS.pdf
├── irlml6344pbf.pdf
├── sn74lvc1g00.pdf
├── stm32l051c6.pdf
├── tps61020.pdf
├── 备选
├── DS3231M.pdf
├── GDEH029A1-Specificationf2c2.pdf
├── SMD_AAA_1022.PDF
└── tps61099.pdf
└── 应用手册
├── Low-Power Modes on the STM32L0 Series - Microcontroller - eewiki.pdf
├── STM32_VREF.pdf
├── Sensirion_Humidity_Design_Guide_V1.pdf
├── Sensirion_Humidity_Sensors_SHT3x_Application_Note_Alert_Mode_DIS.pdf
├── dm00104451-cortexm0-programming-manual-for-stm32l0-stm32g0-stm32wl-and-stm32wb-series-stmicroelectronics.pdf
├── dm00108282-ultralowpower-stm32l0x1-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
├── dm00114897-stm32l051x68-device-limitations-stmicroelectronics.pdf
├── dm00315319-stm32-gpio-configuration-for-hardware-settings-and-lowpower-consumption-stmicroelectronics.pdf
├── slva139 battery.pdf
├── slva194.pdf
├── slva315 battery.pdf
└── slva387.pdf
/.gitignore:
--------------------------------------------------------------------------------
1 | # 忽略Keil中间文件
2 | *.bak
3 | *.ddk
4 | *.edk
5 | *.lst
6 | *.lnp
7 | *.mpf
8 | *.mpj
9 | *.obj
10 | *.omf
11 | *.plg
12 | *.rpt
13 | *.tmp
14 | *.__i
15 | *.crf
16 | *.o
17 | *.d
18 | *.axf
19 | *.tra
20 | *.dep
21 | *.iex
22 | *.htm
23 | *.sct
24 | *.map
25 | JLinkLog.txt
26 |
27 | # 忽略其他文件
28 | *.mxproject
29 | *.izilzty
30 |
31 | # 不忽略的文件
32 | !资源/**
--------------------------------------------------------------------------------
/.vscode/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "STM32",
5 | "includePath": [
6 | "${workspaceFolder}/**",
7 | "D:/Keil_v5/ARM/ARMCLANG/include/"
8 | ],
9 | "defines": [
10 | "USE_FULL_LL_DRIVER",
11 | "HSE_VALUE=8000000",
12 | "HSE_STARTUP_TIMEOUT=100",
13 | "LSE_STARTUP_TIMEOUT=5000",
14 | "LSE_VALUE=32768",
15 | "MSI_VALUE=2097000",
16 | "HSI_VALUE=16000000",
17 | "LSI_VALUE=37000",
18 | "VDD_VALUE=3300",
19 | "PREFETCH_ENABLE=0",
20 | "INSTRUCTION_CACHE_ENABLE=1",
21 | "DATA_CACHE_ENABLE=1",
22 | "STM32L051xx",
23 | "__CC_ARM"
24 | ],
25 | "cStandard": "c99",
26 | "intelliSenseMode": "clang-arm"
27 | }
28 | ],
29 | "version": 4
30 | }
31 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.autoSave": "onWindowChange",
3 | "files.associations": {
4 | "*.c": "c",
5 | "*.h": "c",
6 | "*.C": "c",
7 | "*.H": "c"
8 | }
9 | }
--------------------------------------------------------------------------------
/Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32l0xx.h
4 | * @author MCD Application Team
5 | * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Header File.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | *
© Copyright(c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /** @addtogroup CMSIS
21 | * @{
22 | */
23 |
24 | /** @addtogroup stm32l0xx_system
25 | * @{
26 | */
27 |
28 | /**
29 | * @brief Define to prevent recursive inclusion
30 | */
31 | #ifndef __SYSTEM_STM32L0XX_H
32 | #define __SYSTEM_STM32L0XX_H
33 |
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | /** @addtogroup STM32L0xx_System_Includes
39 | * @{
40 | */
41 |
42 | /**
43 | * @}
44 | */
45 |
46 |
47 | /** @addtogroup STM32L0xx_System_Exported_types
48 | * @{
49 | */
50 | /* This variable is updated in three ways:
51 | 1) by calling CMSIS function SystemCoreClockUpdate()
52 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq()
53 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
54 | Note: If you use this function to configure the system clock; then there
55 | is no need to call the 2 first functions listed above, since SystemCoreClock
56 | variable is updated automatically.
57 | */
58 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
59 | /*
60 | */
61 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */
62 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */
63 | extern const uint8_t PLLMulTable[9]; /*!< PLL multipiers table values */
64 |
65 |
66 | /**
67 | * @}
68 | */
69 |
70 | /** @addtogroup STM32L0xx_System_Exported_Constants
71 | * @{
72 | */
73 |
74 | /**
75 | * @}
76 | */
77 |
78 | /** @addtogroup STM32L0xx_System_Exported_Macros
79 | * @{
80 | */
81 |
82 | /**
83 | * @}
84 | */
85 |
86 | /** @addtogroup STM32L0xx_System_Exported_Functions
87 | * @{
88 | */
89 |
90 | extern void SystemInit(void);
91 | extern void SystemCoreClockUpdate(void);
92 | /**
93 | * @}
94 | */
95 |
96 | #ifdef __cplusplus
97 | }
98 | #endif
99 |
100 | #endif /*__SYSTEM_STM32L0XX_H */
101 |
102 | /**
103 | * @}
104 | */
105 |
106 | /**
107 | * @}
108 | */
109 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
110 |
--------------------------------------------------------------------------------
/Drivers/CMSIS/Include/arm_common_tables.h:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------
2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
3 | *
4 | * $Date: 19. October 2015
5 | * $Revision: V.1.4.5 a
6 | *
7 | * Project: CMSIS DSP Library
8 | * Title: arm_common_tables.h
9 | *
10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions
11 | *
12 | * Target Processor: Cortex-M4/Cortex-M3
13 | *
14 | * Redistribution and use in source and binary forms, with or without
15 | * modification, are permitted provided that the following conditions
16 | * are met:
17 | * - Redistributions of source code must retain the above copyright
18 | * notice, this list of conditions and the following disclaimer.
19 | * - Redistributions in binary form must reproduce the above copyright
20 | * notice, this list of conditions and the following disclaimer in
21 | * the documentation and/or other materials provided with the
22 | * distribution.
23 | * - Neither the name of ARM LIMITED nor the names of its contributors
24 | * may be used to endorse or promote products derived from this
25 | * software without specific prior written permission.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 | * POSSIBILITY OF SUCH DAMAGE.
39 | * -------------------------------------------------------------------- */
40 |
41 | #ifndef _ARM_COMMON_TABLES_H
42 | #define _ARM_COMMON_TABLES_H
43 |
44 | #include "arm_math.h"
45 |
46 | extern const uint16_t armBitRevTable[1024];
47 | extern const q15_t armRecipTableQ15[64];
48 | extern const q31_t armRecipTableQ31[64];
49 | /* extern const q31_t realCoefAQ31[1024]; */
50 | /* extern const q31_t realCoefBQ31[1024]; */
51 | extern const float32_t twiddleCoef_16[32];
52 | extern const float32_t twiddleCoef_32[64];
53 | extern const float32_t twiddleCoef_64[128];
54 | extern const float32_t twiddleCoef_128[256];
55 | extern const float32_t twiddleCoef_256[512];
56 | extern const float32_t twiddleCoef_512[1024];
57 | extern const float32_t twiddleCoef_1024[2048];
58 | extern const float32_t twiddleCoef_2048[4096];
59 | extern const float32_t twiddleCoef_4096[8192];
60 | #define twiddleCoef twiddleCoef_4096
61 | extern const q31_t twiddleCoef_16_q31[24];
62 | extern const q31_t twiddleCoef_32_q31[48];
63 | extern const q31_t twiddleCoef_64_q31[96];
64 | extern const q31_t twiddleCoef_128_q31[192];
65 | extern const q31_t twiddleCoef_256_q31[384];
66 | extern const q31_t twiddleCoef_512_q31[768];
67 | extern const q31_t twiddleCoef_1024_q31[1536];
68 | extern const q31_t twiddleCoef_2048_q31[3072];
69 | extern const q31_t twiddleCoef_4096_q31[6144];
70 | extern const q15_t twiddleCoef_16_q15[24];
71 | extern const q15_t twiddleCoef_32_q15[48];
72 | extern const q15_t twiddleCoef_64_q15[96];
73 | extern const q15_t twiddleCoef_128_q15[192];
74 | extern const q15_t twiddleCoef_256_q15[384];
75 | extern const q15_t twiddleCoef_512_q15[768];
76 | extern const q15_t twiddleCoef_1024_q15[1536];
77 | extern const q15_t twiddleCoef_2048_q15[3072];
78 | extern const q15_t twiddleCoef_4096_q15[6144];
79 | extern const float32_t twiddleCoef_rfft_32[32];
80 | extern const float32_t twiddleCoef_rfft_64[64];
81 | extern const float32_t twiddleCoef_rfft_128[128];
82 | extern const float32_t twiddleCoef_rfft_256[256];
83 | extern const float32_t twiddleCoef_rfft_512[512];
84 | extern const float32_t twiddleCoef_rfft_1024[1024];
85 | extern const float32_t twiddleCoef_rfft_2048[2048];
86 | extern const float32_t twiddleCoef_rfft_4096[4096];
87 |
88 |
89 | /* floating-point bit reversal tables */
90 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 )
91 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 )
92 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 )
93 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 )
94 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 )
95 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 )
96 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800)
97 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808)
98 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032)
99 |
100 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH];
101 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH];
102 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH];
103 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH];
104 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH];
105 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH];
106 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH];
107 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH];
108 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH];
109 |
110 | /* fixed-point bit reversal tables */
111 | #define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 )
112 | #define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 )
113 | #define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 )
114 | #define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 )
115 | #define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 )
116 | #define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 )
117 | #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 )
118 | #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984)
119 | #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032)
120 |
121 | extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH];
122 | extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH];
123 | extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH];
124 | extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH];
125 | extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH];
126 | extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH];
127 | extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH];
128 | extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH];
129 | extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH];
130 |
131 | /* Tables for Fast Math Sine and Cosine */
132 | extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1];
133 | extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1];
134 | extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1];
135 |
136 | #endif /* ARM_COMMON_TABLES_H */
137 |
--------------------------------------------------------------------------------
/Drivers/CMSIS/Include/arm_const_structs.h:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------
2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
3 | *
4 | * $Date: 19. March 2015
5 | * $Revision: V.1.4.5
6 | *
7 | * Project: CMSIS DSP Library
8 | * Title: arm_const_structs.h
9 | *
10 | * Description: This file has constant structs that are initialized for
11 | * user convenience. For example, some can be given as
12 | * arguments to the arm_cfft_f32() function.
13 | *
14 | * Target Processor: Cortex-M4/Cortex-M3
15 | *
16 | * Redistribution and use in source and binary forms, with or without
17 | * modification, are permitted provided that the following conditions
18 | * are met:
19 | * - Redistributions of source code must retain the above copyright
20 | * notice, this list of conditions and the following disclaimer.
21 | * - Redistributions in binary form must reproduce the above copyright
22 | * notice, this list of conditions and the following disclaimer in
23 | * the documentation and/or other materials provided with the
24 | * distribution.
25 | * - Neither the name of ARM LIMITED nor the names of its contributors
26 | * may be used to endorse or promote products derived from this
27 | * software without specific prior written permission.
28 | *
29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 | * POSSIBILITY OF SUCH DAMAGE.
41 | * -------------------------------------------------------------------- */
42 |
43 | #ifndef _ARM_CONST_STRUCTS_H
44 | #define _ARM_CONST_STRUCTS_H
45 |
46 | #include "arm_math.h"
47 | #include "arm_common_tables.h"
48 |
49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16;
50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32;
51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64;
52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128;
53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256;
54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512;
55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024;
56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048;
57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096;
58 |
59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16;
60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32;
61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64;
62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128;
63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256;
64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512;
65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024;
66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048;
67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096;
68 |
69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16;
70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32;
71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64;
72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128;
73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256;
74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512;
75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024;
76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048;
77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096;
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/Drivers/CMSIS/Include/core_cmFunc.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file core_cmFunc.h
3 | * @brief CMSIS Cortex-M Core Function Access Header File
4 | * @version V4.30
5 | * @date 20. October 2015
6 | ******************************************************************************/
7 | /* Copyright (c) 2009 - 2015 ARM LIMITED
8 |
9 | All rights reserved.
10 | Redistribution and use in source and binary forms, with or without
11 | modification, are permitted provided that the following conditions are met:
12 | - Redistributions of source code must retain the above copyright
13 | notice, this list of conditions and the following disclaimer.
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 | - Neither the name of ARM nor the names of its contributors may be used
18 | to endorse or promote products derived from this software without
19 | specific prior written permission.
20 | *
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | POSSIBILITY OF SUCH DAMAGE.
32 | ---------------------------------------------------------------------------*/
33 |
34 |
35 | #if defined ( __ICCARM__ )
36 | #pragma system_include /* treat file as system include file for MISRA check */
37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38 | #pragma clang system_header /* treat file as system include file */
39 | #endif
40 |
41 | #ifndef __CORE_CMFUNC_H
42 | #define __CORE_CMFUNC_H
43 |
44 |
45 | /* ########################### Core Function Access ########################### */
46 | /** \ingroup CMSIS_Core_FunctionInterface
47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
48 | @{
49 | */
50 |
51 | /*------------------ RealView Compiler -----------------*/
52 | #if defined ( __CC_ARM )
53 | #include "cmsis_armcc.h"
54 |
55 | /*------------------ ARM Compiler V6 -------------------*/
56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
57 | #include "cmsis_armcc_V6.h"
58 |
59 | /*------------------ GNU Compiler ----------------------*/
60 | #elif defined ( __GNUC__ )
61 | #include "cmsis_gcc.h"
62 |
63 | /*------------------ ICC Compiler ----------------------*/
64 | #elif defined ( __ICCARM__ )
65 | #include
66 |
67 | /*------------------ TI CCS Compiler -------------------*/
68 | #elif defined ( __TMS470__ )
69 | #include
70 |
71 | /*------------------ TASKING Compiler ------------------*/
72 | #elif defined ( __TASKING__ )
73 | /*
74 | * The CMSIS functions have been implemented as intrinsics in the compiler.
75 | * Please use "carm -?i" to get an up to date list of all intrinsics,
76 | * Including the CMSIS ones.
77 | */
78 |
79 | /*------------------ COSMIC Compiler -------------------*/
80 | #elif defined ( __CSMC__ )
81 | #include
82 |
83 | #endif
84 |
85 | /*@} end of CMSIS_Core_RegAccFunctions */
86 |
87 | #endif /* __CORE_CMFUNC_H */
88 |
--------------------------------------------------------------------------------
/Drivers/CMSIS/Include/core_cmInstr.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file core_cmInstr.h
3 | * @brief CMSIS Cortex-M Core Instruction Access Header File
4 | * @version V4.30
5 | * @date 20. October 2015
6 | ******************************************************************************/
7 | /* Copyright (c) 2009 - 2015 ARM LIMITED
8 |
9 | All rights reserved.
10 | Redistribution and use in source and binary forms, with or without
11 | modification, are permitted provided that the following conditions are met:
12 | - Redistributions of source code must retain the above copyright
13 | notice, this list of conditions and the following disclaimer.
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 | - Neither the name of ARM nor the names of its contributors may be used
18 | to endorse or promote products derived from this software without
19 | specific prior written permission.
20 | *
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | POSSIBILITY OF SUCH DAMAGE.
32 | ---------------------------------------------------------------------------*/
33 |
34 |
35 | #if defined ( __ICCARM__ )
36 | #pragma system_include /* treat file as system include file for MISRA check */
37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38 | #pragma clang system_header /* treat file as system include file */
39 | #endif
40 |
41 | #ifndef __CORE_CMINSTR_H
42 | #define __CORE_CMINSTR_H
43 |
44 |
45 | /* ########################## Core Instruction Access ######################### */
46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
47 | Access to dedicated instructions
48 | @{
49 | */
50 |
51 | /*------------------ RealView Compiler -----------------*/
52 | #if defined ( __CC_ARM )
53 | #include "cmsis_armcc.h"
54 |
55 | /*------------------ ARM Compiler V6 -------------------*/
56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
57 | #include "cmsis_armcc_V6.h"
58 |
59 | /*------------------ GNU Compiler ----------------------*/
60 | #elif defined ( __GNUC__ )
61 | #include "cmsis_gcc.h"
62 |
63 | /*------------------ ICC Compiler ----------------------*/
64 | #elif defined ( __ICCARM__ )
65 | #include
66 |
67 | /*------------------ TI CCS Compiler -------------------*/
68 | #elif defined ( __TMS470__ )
69 | #include
70 |
71 | /*------------------ TASKING Compiler ------------------*/
72 | #elif defined ( __TASKING__ )
73 | /*
74 | * The CMSIS functions have been implemented as intrinsics in the compiler.
75 | * Please use "carm -?i" to get an up to date list of all intrinsics,
76 | * Including the CMSIS ones.
77 | */
78 |
79 | /*------------------ COSMIC Compiler -------------------*/
80 | #elif defined ( __CSMC__ )
81 | #include
82 |
83 | #endif
84 |
85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
86 |
87 | #endif /* __CORE_CMINSTR_H */
88 |
--------------------------------------------------------------------------------
/Drivers/CMSIS/Include/core_cmSimd.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file core_cmSimd.h
3 | * @brief CMSIS Cortex-M SIMD Header File
4 | * @version V4.30
5 | * @date 20. October 2015
6 | ******************************************************************************/
7 | /* Copyright (c) 2009 - 2015 ARM LIMITED
8 |
9 | All rights reserved.
10 | Redistribution and use in source and binary forms, with or without
11 | modification, are permitted provided that the following conditions are met:
12 | - Redistributions of source code must retain the above copyright
13 | notice, this list of conditions and the following disclaimer.
14 | - Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions and the following disclaimer in the
16 | documentation and/or other materials provided with the distribution.
17 | - Neither the name of ARM nor the names of its contributors may be used
18 | to endorse or promote products derived from this software without
19 | specific prior written permission.
20 | *
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | POSSIBILITY OF SUCH DAMAGE.
32 | ---------------------------------------------------------------------------*/
33 |
34 |
35 | #if defined ( __ICCARM__ )
36 | #pragma system_include /* treat file as system include file for MISRA check */
37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38 | #pragma clang system_header /* treat file as system include file */
39 | #endif
40 |
41 | #ifndef __CORE_CMSIMD_H
42 | #define __CORE_CMSIMD_H
43 |
44 | #ifdef __cplusplus
45 | extern "C" {
46 | #endif
47 |
48 |
49 | /* ################### Compiler specific Intrinsics ########################### */
50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
51 | Access to dedicated SIMD instructions
52 | @{
53 | */
54 |
55 | /*------------------ RealView Compiler -----------------*/
56 | #if defined ( __CC_ARM )
57 | #include "cmsis_armcc.h"
58 |
59 | /*------------------ ARM Compiler V6 -------------------*/
60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
61 | #include "cmsis_armcc_V6.h"
62 |
63 | /*------------------ GNU Compiler ----------------------*/
64 | #elif defined ( __GNUC__ )
65 | #include "cmsis_gcc.h"
66 |
67 | /*------------------ ICC Compiler ----------------------*/
68 | #elif defined ( __ICCARM__ )
69 | #include
70 |
71 | /*------------------ TI CCS Compiler -------------------*/
72 | #elif defined ( __TMS470__ )
73 | #include
74 |
75 | /*------------------ TASKING Compiler ------------------*/
76 | #elif defined ( __TASKING__ )
77 | /*
78 | * The CMSIS functions have been implemented as intrinsics in the compiler.
79 | * Please use "carm -?i" to get an up to date list of all intrinsics,
80 | * Including the CMSIS ones.
81 | */
82 |
83 | /*------------------ COSMIC Compiler -------------------*/
84 | #elif defined ( __CSMC__ )
85 | #include
86 |
87 | #endif
88 |
89 | /*@} end of group CMSIS_SIMD_intrinsics */
90 |
91 |
92 | #ifdef __cplusplus
93 | }
94 | #endif
95 |
96 | #endif /* __CORE_CMSIMD_H */
97 |
--------------------------------------------------------------------------------
/Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32l0xx_ll_utils.h
4 | * @author MCD Application Team
5 | * @brief Header file of UTILS LL module.
6 | @verbatim
7 | ==============================================================================
8 | ##### How to use this driver #####
9 | ==============================================================================
10 | [..]
11 | The LL UTILS driver contains a set of generic APIs that can be
12 | used by user:
13 | (+) Device electronic signature
14 | (+) Timing functions
15 | (+) PLL configuration functions
16 |
17 | @endverbatim
18 | ******************************************************************************
19 | * @attention
20 | *
21 | * © Copyright(c) 2016 STMicroelectronics.
22 | * All rights reserved.
23 | *
24 | * This software component is licensed by ST under BSD 3-Clause license,
25 | * the "License"; You may not use this file except in compliance with the
26 | * License. You may obtain a copy of the License at:
27 | * opensource.org/licenses/BSD-3-Clause
28 | *
29 | ******************************************************************************
30 | */
31 |
32 | /* Define to prevent recursive inclusion -------------------------------------*/
33 | #ifndef __STM32L0xx_LL_UTILS_H
34 | #define __STM32L0xx_LL_UTILS_H
35 |
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif
39 |
40 | /* Includes ------------------------------------------------------------------*/
41 | #include "stm32l0xx.h"
42 |
43 | /** @addtogroup STM32L0xx_LL_Driver
44 | * @{
45 | */
46 |
47 | /** @defgroup UTILS_LL UTILS
48 | * @{
49 | */
50 |
51 | /* Private types -------------------------------------------------------------*/
52 | /* Private variables ---------------------------------------------------------*/
53 |
54 | /* Private constants ---------------------------------------------------------*/
55 | /** @defgroup UTILS_LL_Private_Constants UTILS Private Constants
56 | * @{
57 | */
58 |
59 | /* Max delay can be used in LL_mDelay */
60 | #define LL_MAX_DELAY 0xFFFFFFFFU
61 |
62 | /**
63 | * @brief Unique device ID register base address
64 | */
65 | #define UID_BASE_ADDRESS UID_BASE
66 |
67 | /**
68 | * @brief Flash size data register base address
69 | */
70 | #define FLASHSIZE_BASE_ADDRESS FLASHSIZE_BASE
71 |
72 |
73 | /**
74 | * @}
75 | */
76 |
77 | /* Private macros ------------------------------------------------------------*/
78 | /** @defgroup UTILS_LL_Private_Macros UTILS Private Macros
79 | * @{
80 | */
81 | /**
82 | * @}
83 | */
84 | /* Exported types ------------------------------------------------------------*/
85 | /** @defgroup UTILS_LL_ES_INIT UTILS Exported structures
86 | * @{
87 | */
88 | /**
89 | * @brief UTILS PLL structure definition
90 | */
91 | typedef struct
92 | {
93 | uint32_t PLLMul; /*!< Multiplication factor for PLL VCO input clock.
94 | This parameter can be a value of @ref RCC_LL_EC_PLL_MUL
95 |
96 | This feature can be modified afterwards using unitary function
97 | @ref LL_RCC_PLL_ConfigDomain_SYS(). */
98 |
99 | uint32_t PLLDiv; /*!< Division factor for PLL VCO output clock.
100 | This parameter can be a value of @ref RCC_LL_EC_PLL_DIV
101 |
102 | This feature can be modified afterwards using unitary function
103 | @ref LL_RCC_PLL_ConfigDomain_SYS(). */
104 | } LL_UTILS_PLLInitTypeDef;
105 |
106 | /**
107 | * @brief UTILS System, AHB and APB buses clock configuration structure definition
108 | */
109 | typedef struct
110 | {
111 | uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
112 | This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV
113 |
114 | This feature can be modified afterwards using unitary function
115 | @ref LL_RCC_SetAHBPrescaler(). */
116 |
117 | uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
118 | This parameter can be a value of @ref RCC_LL_EC_APB1_DIV
119 |
120 | This feature can be modified afterwards using unitary function
121 | @ref LL_RCC_SetAPB1Prescaler(). */
122 |
123 | uint32_t APB2CLKDivider; /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
124 | This parameter can be a value of @ref RCC_LL_EC_APB2_DIV
125 |
126 | This feature can be modified afterwards using unitary function
127 | @ref LL_RCC_SetAPB2Prescaler(). */
128 |
129 | } LL_UTILS_ClkInitTypeDef;
130 |
131 | /**
132 | * @}
133 | */
134 |
135 | /* Exported constants --------------------------------------------------------*/
136 | /** @defgroup UTILS_LL_Exported_Constants UTILS Exported Constants
137 | * @{
138 | */
139 |
140 | /** @defgroup UTILS_EC_HSE_BYPASS HSE Bypass activation
141 | * @{
142 | */
143 | #define LL_UTILS_HSEBYPASS_OFF 0x00000000U /*!< HSE Bypass is not enabled */
144 | #define LL_UTILS_HSEBYPASS_ON 0x00000001U /*!< HSE Bypass is enabled */
145 | /**
146 | * @}
147 | */
148 |
149 |
150 | /**
151 | * @}
152 | */
153 |
154 | /* Exported macro ------------------------------------------------------------*/
155 |
156 | /* Exported functions --------------------------------------------------------*/
157 | /** @defgroup UTILS_LL_Exported_Functions UTILS Exported Functions
158 | * @{
159 | */
160 |
161 | /** @defgroup UTILS_EF_DEVICE_ELECTRONIC_SIGNATURE DEVICE ELECTRONIC SIGNATURE
162 | * @{
163 | */
164 |
165 | /**
166 | * @brief Get Word0 of the unique device identifier (UID based on 96 bits)
167 | * @retval UID[31:0]
168 | */
169 | __STATIC_INLINE uint32_t LL_GetUID_Word0(void)
170 | {
171 | return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS)));
172 | }
173 |
174 | /**
175 | * @brief Get Word1 of the unique device identifier (UID based on 96 bits)
176 | * @retval UID[63:32]
177 | */
178 | __STATIC_INLINE uint32_t LL_GetUID_Word1(void)
179 | {
180 | return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 0x04U))));
181 | }
182 |
183 | /**
184 | * @brief Get Word2 of the unique device identifier (UID based on 96 bits)
185 | * @retval UID[95:64]
186 | */
187 | __STATIC_INLINE uint32_t LL_GetUID_Word2(void)
188 | {
189 | return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 0x14U))));
190 | }
191 |
192 | /**
193 | * @brief Get Flash memory size
194 | * @note This bitfield indicates the size of the device Flash memory expressed in
195 | * Kbytes. As an example, 0x040 corresponds to 64 Kbytes.
196 | * @retval FLASH_SIZE[15:0]: Flash memory size
197 | */
198 | __STATIC_INLINE uint32_t LL_GetFlashSize(void)
199 | {
200 | return (uint32_t)(READ_REG(*((uint32_t *)FLASHSIZE_BASE_ADDRESS)) & 0xFFFF);
201 | }
202 |
203 |
204 | /**
205 | * @}
206 | */
207 |
208 | /** @defgroup UTILS_LL_EF_DELAY DELAY
209 | * @{
210 | */
211 |
212 | /**
213 | * @brief This function configures the Cortex-M SysTick source of the time base.
214 | * @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro)
215 | * @note When a RTOS is used, it is recommended to avoid changing the SysTick
216 | * configuration by calling this function, for a delay use rather osDelay RTOS service.
217 | * @param Ticks Number of ticks
218 | * @retval None
219 | */
220 | __STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks)
221 | {
222 | /* Configure the SysTick to have interrupt in 1ms time base */
223 | SysTick->LOAD = (uint32_t)((HCLKFrequency / Ticks) - 1UL); /* set reload register */
224 | SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
225 | SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
226 | SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */
227 | }
228 |
229 | void LL_Init1msTick(uint32_t HCLKFrequency);
230 | void LL_mDelay(uint32_t Delay);
231 |
232 | /**
233 | * @}
234 | */
235 |
236 | /** @defgroup UTILS_EF_SYSTEM SYSTEM
237 | * @{
238 | */
239 |
240 | void LL_SetSystemCoreClock(uint32_t HCLKFrequency);
241 | ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct,
242 | LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct);
243 | ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypass,
244 | LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct);
245 |
246 | /**
247 | * @}
248 | */
249 |
250 | /**
251 | * @}
252 | */
253 |
254 | /**
255 | * @}
256 | */
257 |
258 | /**
259 | * @}
260 | */
261 |
262 | #ifdef __cplusplus
263 | }
264 | #endif
265 |
266 | #endif /* __STM32L0xx_LL_UTILS_H */
267 |
268 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
269 |
--------------------------------------------------------------------------------
/Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_exti.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32l0xx_ll_exti.c
4 | * @author MCD Application Team
5 | * @brief EXTI LL module driver.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright(c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | #if defined(USE_FULL_LL_DRIVER)
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "stm32l0xx_ll_exti.h"
23 | #ifdef USE_FULL_ASSERT
24 | #include "stm32_assert.h"
25 | #else
26 | #define assert_param(expr) ((void)0U)
27 | #endif
28 |
29 | /** @addtogroup STM32L0xx_LL_Driver
30 | * @{
31 | */
32 |
33 | #if defined (EXTI)
34 |
35 | /** @defgroup EXTI_LL EXTI
36 | * @{
37 | */
38 |
39 | /* Private types -------------------------------------------------------------*/
40 | /* Private variables ---------------------------------------------------------*/
41 | /* Private constants ---------------------------------------------------------*/
42 | /* Private macros ------------------------------------------------------------*/
43 | /** @addtogroup EXTI_LL_Private_Macros
44 | * @{
45 | */
46 |
47 | #define IS_LL_EXTI_LINE_0_31(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U)
48 |
49 | #define IS_LL_EXTI_MODE(__VALUE__) (((__VALUE__) == LL_EXTI_MODE_IT) \
50 | || ((__VALUE__) == LL_EXTI_MODE_EVENT) \
51 | || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT))
52 |
53 |
54 | #define IS_LL_EXTI_TRIGGER(__VALUE__) (((__VALUE__) == LL_EXTI_TRIGGER_NONE) \
55 | || ((__VALUE__) == LL_EXTI_TRIGGER_RISING) \
56 | || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING) \
57 | || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING))
58 |
59 | /**
60 | * @}
61 | */
62 |
63 | /* Private function prototypes -----------------------------------------------*/
64 |
65 | /* Exported functions --------------------------------------------------------*/
66 | /** @addtogroup EXTI_LL_Exported_Functions
67 | * @{
68 | */
69 |
70 | /** @addtogroup EXTI_LL_EF_Init
71 | * @{
72 | */
73 |
74 | /**
75 | * @brief De-initialize the EXTI registers to their default reset values.
76 | * @retval An ErrorStatus enumeration value:
77 | * - SUCCESS: EXTI registers are de-initialized
78 | * - ERROR: not applicable
79 | */
80 | uint32_t LL_EXTI_DeInit(void)
81 | {
82 | /* Interrupt mask register set to default reset values */
83 | LL_EXTI_WriteReg(IMR, 0x3F840000U);
84 | /* Event mask register set to default reset values */
85 | LL_EXTI_WriteReg(EMR, 0x00000000U);
86 | /* Rising Trigger selection register set to default reset values */
87 | LL_EXTI_WriteReg(RTSR, 0x00000000U);
88 | /* Falling Trigger selection register set to default reset values */
89 | LL_EXTI_WriteReg(FTSR, 0x00000000U);
90 | /* Software interrupt event register set to default reset values */
91 | LL_EXTI_WriteReg(SWIER, 0x00000000U);
92 | /* Pending register set to default reset values */
93 | LL_EXTI_WriteReg(PR, 0x007BFFFFU);
94 |
95 | return SUCCESS;
96 | }
97 |
98 | /**
99 | * @brief Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct.
100 | * @param EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure.
101 | * @retval An ErrorStatus enumeration value:
102 | * - SUCCESS: EXTI registers are initialized
103 | * - ERROR: not applicable
104 | */
105 | uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct)
106 | {
107 | ErrorStatus status = SUCCESS;
108 | /* Check the parameters */
109 | assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31));
110 | assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand));
111 | assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode));
112 |
113 | /* ENABLE LineCommand */
114 | if (EXTI_InitStruct->LineCommand != DISABLE)
115 | {
116 | assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger));
117 |
118 | /* Configure EXTI Lines in range from 0 to 31 */
119 | if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE)
120 | {
121 | switch (EXTI_InitStruct->Mode)
122 | {
123 | case LL_EXTI_MODE_IT:
124 | /* First Disable Event on provided Lines */
125 | LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
126 | /* Then Enable IT on provided Lines */
127 | LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
128 | break;
129 | case LL_EXTI_MODE_EVENT:
130 | /* First Disable IT on provided Lines */
131 | LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
132 | /* Then Enable Event on provided Lines */
133 | LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
134 | break;
135 | case LL_EXTI_MODE_IT_EVENT:
136 | /* Directly Enable IT & Event on provided Lines */
137 | LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
138 | LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
139 | break;
140 | default:
141 | status = ERROR;
142 | break;
143 | }
144 | if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
145 | {
146 | switch (EXTI_InitStruct->Trigger)
147 | {
148 | case LL_EXTI_TRIGGER_RISING:
149 | /* First Disable Falling Trigger on provided Lines */
150 | LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
151 | /* Then Enable Rising Trigger on provided Lines */
152 | LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
153 | break;
154 | case LL_EXTI_TRIGGER_FALLING:
155 | /* First Disable Rising Trigger on provided Lines */
156 | LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
157 | /* Then Enable Falling Trigger on provided Lines */
158 | LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
159 | break;
160 | case LL_EXTI_TRIGGER_RISING_FALLING:
161 | LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
162 | LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
163 | break;
164 | default:
165 | status = ERROR;
166 | break;
167 | }
168 | }
169 | }
170 | }
171 | /* DISABLE LineCommand */
172 | else
173 | {
174 | /* De-configure EXTI Lines in range from 0 to 31 */
175 | LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
176 | LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
177 | }
178 | return status;
179 | }
180 |
181 | /**
182 | * @brief Set each @ref LL_EXTI_InitTypeDef field to default value.
183 | * @param EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure.
184 | * @retval None
185 | */
186 | void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct)
187 | {
188 | EXTI_InitStruct->Line_0_31 = LL_EXTI_LINE_NONE;
189 | EXTI_InitStruct->LineCommand = DISABLE;
190 | EXTI_InitStruct->Mode = LL_EXTI_MODE_IT;
191 | EXTI_InitStruct->Trigger = LL_EXTI_TRIGGER_FALLING;
192 | }
193 |
194 | /**
195 | * @}
196 | */
197 |
198 | /**
199 | * @}
200 | */
201 |
202 | /**
203 | * @}
204 | */
205 |
206 | #endif /* defined (EXTI) */
207 |
208 | /**
209 | * @}
210 | */
211 |
212 | #endif /* USE_FULL_LL_DRIVER */
213 |
214 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
215 |
--------------------------------------------------------------------------------
/Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_gpio.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32l0xx_ll_gpio.c
4 | * @author MCD Application Team
5 | * @brief GPIO LL module driver.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright(c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | #if defined(USE_FULL_LL_DRIVER)
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "stm32l0xx_ll_gpio.h"
23 | #include "stm32l0xx_ll_bus.h"
24 | #ifdef USE_FULL_ASSERT
25 | #include "stm32_assert.h"
26 | #else
27 | #define assert_param(expr) ((void)0U)
28 | #endif
29 |
30 | /** @addtogroup STM32L0xx_LL_Driver
31 | * @{
32 | */
33 |
34 | #if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOH)
35 |
36 | /** @addtogroup GPIO_LL
37 | * @{
38 | */
39 |
40 | /* Private types -------------------------------------------------------------*/
41 | /* Private variables ---------------------------------------------------------*/
42 | /* Private constants ---------------------------------------------------------*/
43 | /* Private macros ------------------------------------------------------------*/
44 | /** @addtogroup GPIO_LL_Private_Macros
45 | * @{
46 | */
47 | #define IS_LL_GPIO_PIN(__VALUE__) ((((uint32_t)0x00000000U) < (__VALUE__)) && ((__VALUE__) <= (LL_GPIO_PIN_ALL)))
48 |
49 | #define IS_LL_GPIO_MODE(__VALUE__) (((__VALUE__) == LL_GPIO_MODE_INPUT) ||\
50 | ((__VALUE__) == LL_GPIO_MODE_OUTPUT) ||\
51 | ((__VALUE__) == LL_GPIO_MODE_ALTERNATE) ||\
52 | ((__VALUE__) == LL_GPIO_MODE_ANALOG))
53 |
54 | #define IS_LL_GPIO_OUTPUT_TYPE(__VALUE__) (((__VALUE__) == LL_GPIO_OUTPUT_PUSHPULL) ||\
55 | ((__VALUE__) == LL_GPIO_OUTPUT_OPENDRAIN))
56 |
57 | #define IS_LL_GPIO_SPEED(__VALUE__) (((__VALUE__) == LL_GPIO_SPEED_FREQ_LOW) ||\
58 | ((__VALUE__) == LL_GPIO_SPEED_FREQ_MEDIUM) ||\
59 | ((__VALUE__) == LL_GPIO_SPEED_FREQ_HIGH) ||\
60 | ((__VALUE__) == LL_GPIO_SPEED_FREQ_VERY_HIGH))
61 |
62 | #define IS_LL_GPIO_PULL(__VALUE__) (((__VALUE__) == LL_GPIO_PULL_NO) ||\
63 | ((__VALUE__) == LL_GPIO_PULL_UP) ||\
64 | ((__VALUE__) == LL_GPIO_PULL_DOWN))
65 |
66 | #define IS_LL_GPIO_ALTERNATE(__VALUE__) (((__VALUE__) == LL_GPIO_AF_0 ) ||\
67 | ((__VALUE__) == LL_GPIO_AF_1 ) ||\
68 | ((__VALUE__) == LL_GPIO_AF_2 ) ||\
69 | ((__VALUE__) == LL_GPIO_AF_3 ) ||\
70 | ((__VALUE__) == LL_GPIO_AF_4 ) ||\
71 | ((__VALUE__) == LL_GPIO_AF_5 ) ||\
72 | ((__VALUE__) == LL_GPIO_AF_6 ) ||\
73 | ((__VALUE__) == LL_GPIO_AF_7 ))
74 | /**
75 | * @}
76 | */
77 |
78 | /* Private function prototypes -----------------------------------------------*/
79 |
80 | /* Exported functions --------------------------------------------------------*/
81 | /** @addtogroup GPIO_LL_Exported_Functions
82 | * @{
83 | */
84 |
85 | /** @addtogroup GPIO_LL_EF_Init
86 | * @{
87 | */
88 |
89 | /**
90 | * @brief De-initialize GPIO registers (Registers restored to their default values).
91 | * @param GPIOx GPIO Port
92 | * @retval An ErrorStatus enumeration value:
93 | * - SUCCESS: GPIO registers are de-initialized
94 | * - ERROR: Wrong GPIO Port
95 | */
96 | ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx)
97 | {
98 | ErrorStatus status = SUCCESS;
99 |
100 | /* Check the parameters */
101 | assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
102 |
103 | /* Force and Release reset on clock of GPIOx Port */
104 | if (GPIOx == GPIOA)
105 | {
106 | LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOA);
107 | LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOA);
108 | }
109 | else if (GPIOx == GPIOB)
110 | {
111 | LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOB);
112 | LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOB);
113 | }
114 | else if (GPIOx == GPIOC)
115 | {
116 | LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOC);
117 | LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOC);
118 | }
119 | #if defined(GPIOD)
120 | else if (GPIOx == GPIOD)
121 | {
122 | LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOD);
123 | LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOD);
124 | }
125 | #endif /* GPIOD */
126 | #if defined(GPIOE)
127 | else if (GPIOx == GPIOE)
128 | {
129 | LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOE);
130 | LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOE);
131 | }
132 | #endif /* GPIOE */
133 | #if defined(GPIOH)
134 | else if (GPIOx == GPIOH)
135 | {
136 | LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOH);
137 | LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOH);
138 | }
139 | #endif /* GPIOH */
140 | else
141 | {
142 | status = ERROR;
143 | }
144 |
145 | return (status);
146 | }
147 |
148 | /**
149 | * @brief Initialize GPIO registers according to the specified parameters in GPIO_InitStruct.
150 | * @param GPIOx GPIO Port
151 | * @param GPIO_InitStruct pointer to a @ref LL_GPIO_InitTypeDef structure
152 | * that contains the configuration information for the specified GPIO peripheral.
153 | * @retval An ErrorStatus enumeration value:
154 | * - SUCCESS: GPIO registers are initialized according to GPIO_InitStruct content
155 | * - ERROR: Not applicable
156 | */
157 | ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct)
158 | {
159 | uint32_t pinpos = 0x00000000U;
160 | uint32_t currentpin = 0x00000000U;
161 |
162 | /* Check the parameters */
163 | assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
164 | assert_param(IS_LL_GPIO_PIN(GPIO_InitStruct->Pin));
165 | assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode));
166 | assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull));
167 |
168 | /* ------------------------- Configure the port pins ---------------- */
169 | /* Initialize pinpos on first pin set */
170 | /* pinpos = 0; useless as already done in default initialization */
171 |
172 | /* Configure the port pins */
173 | while (((GPIO_InitStruct->Pin) >> pinpos) != 0x00000000U)
174 | {
175 | /* Get current io position */
176 | currentpin = (GPIO_InitStruct->Pin) & (0x00000001U << pinpos);
177 |
178 | if (currentpin)
179 | {
180 | if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE))
181 | {
182 | /* Check Speed mode parameters */
183 | assert_param(IS_LL_GPIO_SPEED(GPIO_InitStruct->Speed));
184 |
185 | /* Speed mode configuration */
186 | LL_GPIO_SetPinSpeed(GPIOx, currentpin, GPIO_InitStruct->Speed);
187 |
188 | /* Check Output mode parameters */
189 | assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType));
190 |
191 | /* Output mode configuration*/
192 | LL_GPIO_SetPinOutputType(GPIOx, GPIO_InitStruct->Pin, GPIO_InitStruct->OutputType);
193 | }
194 |
195 | /* Pull-up Pull down resistor configuration*/
196 | LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull);
197 |
198 | if (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)
199 | {
200 | /* Check Alternate parameter */
201 | assert_param(IS_LL_GPIO_ALTERNATE(GPIO_InitStruct->Alternate));
202 |
203 | /* Speed mode configuration */
204 | if (currentpin < LL_GPIO_PIN_8)
205 | {
206 | LL_GPIO_SetAFPin_0_7(GPIOx, currentpin, GPIO_InitStruct->Alternate);
207 | }
208 | else
209 | {
210 | LL_GPIO_SetAFPin_8_15(GPIOx, currentpin, GPIO_InitStruct->Alternate);
211 | }
212 | }
213 |
214 | /* Pin Mode configuration */
215 | LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode);
216 | }
217 | pinpos++;
218 | }
219 |
220 |
221 | return (SUCCESS);
222 | }
223 |
224 | /**
225 | * @brief Set each @ref LL_GPIO_InitTypeDef field to default value.
226 | * @param GPIO_InitStruct: pointer to a @ref LL_GPIO_InitTypeDef structure
227 | * whose fields will be set to default values.
228 | * @retval None
229 | */
230 |
231 | void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct)
232 | {
233 | /* Reset GPIO init structure parameters values */
234 | GPIO_InitStruct->Pin = LL_GPIO_PIN_ALL;
235 | GPIO_InitStruct->Mode = LL_GPIO_MODE_ANALOG;
236 | GPIO_InitStruct->Speed = LL_GPIO_SPEED_FREQ_LOW;
237 | GPIO_InitStruct->OutputType = LL_GPIO_OUTPUT_PUSHPULL;
238 | GPIO_InitStruct->Pull = LL_GPIO_PULL_NO;
239 | GPIO_InitStruct->Alternate = LL_GPIO_AF_0;
240 | }
241 |
242 | /**
243 | * @}
244 | */
245 |
246 | /**
247 | * @}
248 | */
249 |
250 | /**
251 | * @}
252 | */
253 |
254 | #endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOH) */
255 |
256 | /**
257 | * @}
258 | */
259 |
260 | #endif /* USE_FULL_LL_DRIVER */
261 |
262 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
263 |
264 |
--------------------------------------------------------------------------------
/Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_i2c.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32l0xx_ll_i2c.c
4 | * @author MCD Application Team
5 | * @brief I2C LL module driver.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | #if defined(USE_FULL_LL_DRIVER)
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "stm32l0xx_ll_i2c.h"
23 | #include "stm32l0xx_ll_bus.h"
24 | #ifdef USE_FULL_ASSERT
25 | #include "stm32_assert.h"
26 | #else
27 | #define assert_param(expr) ((void)0U)
28 | #endif
29 |
30 | /** @addtogroup STM32L0xx_LL_Driver
31 | * @{
32 | */
33 |
34 | #if defined (I2C1) || defined (I2C2) || defined (I2C3)
35 |
36 | /** @defgroup I2C_LL I2C
37 | * @{
38 | */
39 |
40 | /* Private types -------------------------------------------------------------*/
41 | /* Private variables ---------------------------------------------------------*/
42 | /* Private constants ---------------------------------------------------------*/
43 | /* Private macros ------------------------------------------------------------*/
44 | /** @addtogroup I2C_LL_Private_Macros
45 | * @{
46 | */
47 |
48 | #define IS_LL_I2C_PERIPHERAL_MODE(__VALUE__) (((__VALUE__) == LL_I2C_MODE_I2C) || \
49 | ((__VALUE__) == LL_I2C_MODE_SMBUS_HOST) || \
50 | ((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE) || \
51 | ((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE_ARP))
52 |
53 | #define IS_LL_I2C_ANALOG_FILTER(__VALUE__) (((__VALUE__) == LL_I2C_ANALOGFILTER_ENABLE) || \
54 | ((__VALUE__) == LL_I2C_ANALOGFILTER_DISABLE))
55 |
56 | #define IS_LL_I2C_DIGITAL_FILTER(__VALUE__) ((__VALUE__) <= 0x0000000FU)
57 |
58 | #define IS_LL_I2C_OWN_ADDRESS1(__VALUE__) ((__VALUE__) <= 0x000003FFU)
59 |
60 | #define IS_LL_I2C_TYPE_ACKNOWLEDGE(__VALUE__) (((__VALUE__) == LL_I2C_ACK) || \
61 | ((__VALUE__) == LL_I2C_NACK))
62 |
63 | #define IS_LL_I2C_OWN_ADDRSIZE(__VALUE__) (((__VALUE__) == LL_I2C_OWNADDRESS1_7BIT) || \
64 | ((__VALUE__) == LL_I2C_OWNADDRESS1_10BIT))
65 | /**
66 | * @}
67 | */
68 |
69 | /* Private function prototypes -----------------------------------------------*/
70 |
71 | /* Exported functions --------------------------------------------------------*/
72 | /** @addtogroup I2C_LL_Exported_Functions
73 | * @{
74 | */
75 |
76 | /** @addtogroup I2C_LL_EF_Init
77 | * @{
78 | */
79 |
80 | /**
81 | * @brief De-initialize the I2C registers to their default reset values.
82 | * @param I2Cx I2C Instance.
83 | * @retval An ErrorStatus enumeration value:
84 | * - SUCCESS: I2C registers are de-initialized
85 | * - ERROR: I2C registers are not de-initialized
86 | */
87 | ErrorStatus LL_I2C_DeInit(I2C_TypeDef *I2Cx)
88 | {
89 | ErrorStatus status = SUCCESS;
90 |
91 | /* Check the I2C Instance I2Cx */
92 | assert_param(IS_I2C_ALL_INSTANCE(I2Cx));
93 |
94 | if (I2Cx == I2C1)
95 | {
96 | /* Force reset of I2C clock */
97 | LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C1);
98 |
99 | /* Release reset of I2C clock */
100 | LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C1);
101 | }
102 | #if defined(I2C2)
103 | else if (I2Cx == I2C2)
104 | {
105 | /* Force reset of I2C clock */
106 | LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C2);
107 |
108 | /* Release reset of I2C clock */
109 | LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C2);
110 |
111 | }
112 | #endif
113 | #if defined(I2C3)
114 | else if (I2Cx == I2C3)
115 | {
116 | /* Force reset of I2C clock */
117 | LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C3);
118 |
119 | /* Release reset of I2C clock */
120 | LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C3);
121 | }
122 | #endif
123 | else
124 | {
125 | status = ERROR;
126 | }
127 |
128 | return status;
129 | }
130 |
131 | /**
132 | * @brief Initialize the I2C registers according to the specified parameters in I2C_InitStruct.
133 | * @param I2Cx I2C Instance.
134 | * @param I2C_InitStruct pointer to a @ref LL_I2C_InitTypeDef structure.
135 | * @retval An ErrorStatus enumeration value:
136 | * - SUCCESS: I2C registers are initialized
137 | * - ERROR: Not applicable
138 | */
139 | ErrorStatus LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct)
140 | {
141 | /* Check the I2C Instance I2Cx */
142 | assert_param(IS_I2C_ALL_INSTANCE(I2Cx));
143 |
144 | /* Check the I2C parameters from I2C_InitStruct */
145 | assert_param(IS_LL_I2C_PERIPHERAL_MODE(I2C_InitStruct->PeripheralMode));
146 | assert_param(IS_LL_I2C_ANALOG_FILTER(I2C_InitStruct->AnalogFilter));
147 | assert_param(IS_LL_I2C_DIGITAL_FILTER(I2C_InitStruct->DigitalFilter));
148 | assert_param(IS_LL_I2C_OWN_ADDRESS1(I2C_InitStruct->OwnAddress1));
149 | assert_param(IS_LL_I2C_TYPE_ACKNOWLEDGE(I2C_InitStruct->TypeAcknowledge));
150 | assert_param(IS_LL_I2C_OWN_ADDRSIZE(I2C_InitStruct->OwnAddrSize));
151 |
152 | /* Disable the selected I2Cx Peripheral */
153 | LL_I2C_Disable(I2Cx);
154 |
155 | /*---------------------------- I2Cx CR1 Configuration ------------------------
156 | * Configure the analog and digital noise filters with parameters :
157 | * - AnalogFilter: I2C_CR1_ANFOFF bit
158 | * - DigitalFilter: I2C_CR1_DNF[3:0] bits
159 | */
160 | LL_I2C_ConfigFilters(I2Cx, I2C_InitStruct->AnalogFilter, I2C_InitStruct->DigitalFilter);
161 |
162 | /*---------------------------- I2Cx TIMINGR Configuration --------------------
163 | * Configure the SDA setup, hold time and the SCL high, low period with parameter :
164 | * - Timing: I2C_TIMINGR_PRESC[3:0], I2C_TIMINGR_SCLDEL[3:0], I2C_TIMINGR_SDADEL[3:0],
165 | * I2C_TIMINGR_SCLH[7:0] and I2C_TIMINGR_SCLL[7:0] bits
166 | */
167 | LL_I2C_SetTiming(I2Cx, I2C_InitStruct->Timing);
168 |
169 | /* Enable the selected I2Cx Peripheral */
170 | LL_I2C_Enable(I2Cx);
171 |
172 | /*---------------------------- I2Cx OAR1 Configuration -----------------------
173 | * Disable, Configure and Enable I2Cx device own address 1 with parameters :
174 | * - OwnAddress1: I2C_OAR1_OA1[9:0] bits
175 | * - OwnAddrSize: I2C_OAR1_OA1MODE bit
176 | */
177 | LL_I2C_DisableOwnAddress1(I2Cx);
178 | LL_I2C_SetOwnAddress1(I2Cx, I2C_InitStruct->OwnAddress1, I2C_InitStruct->OwnAddrSize);
179 |
180 | /* OwnAdress1 == 0 is reserved for General Call address */
181 | if (I2C_InitStruct->OwnAddress1 != 0U)
182 | {
183 | LL_I2C_EnableOwnAddress1(I2Cx);
184 | }
185 |
186 | /*---------------------------- I2Cx MODE Configuration -----------------------
187 | * Configure I2Cx peripheral mode with parameter :
188 | * - PeripheralMode: I2C_CR1_SMBDEN and I2C_CR1_SMBHEN bits
189 | */
190 | LL_I2C_SetMode(I2Cx, I2C_InitStruct->PeripheralMode);
191 |
192 | /*---------------------------- I2Cx CR2 Configuration ------------------------
193 | * Configure the ACKnowledge or Non ACKnowledge condition
194 | * after the address receive match code or next received byte with parameter :
195 | * - TypeAcknowledge: I2C_CR2_NACK bit
196 | */
197 | LL_I2C_AcknowledgeNextData(I2Cx, I2C_InitStruct->TypeAcknowledge);
198 |
199 | return SUCCESS;
200 | }
201 |
202 | /**
203 | * @brief Set each @ref LL_I2C_InitTypeDef field to default value.
204 | * @param I2C_InitStruct Pointer to a @ref LL_I2C_InitTypeDef structure.
205 | * @retval None
206 | */
207 | void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct)
208 | {
209 | /* Set I2C_InitStruct fields to default values */
210 | I2C_InitStruct->PeripheralMode = LL_I2C_MODE_I2C;
211 | I2C_InitStruct->Timing = 0U;
212 | I2C_InitStruct->AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE;
213 | I2C_InitStruct->DigitalFilter = 0U;
214 | I2C_InitStruct->OwnAddress1 = 0U;
215 | I2C_InitStruct->TypeAcknowledge = LL_I2C_NACK;
216 | I2C_InitStruct->OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT;
217 | }
218 |
219 | /**
220 | * @}
221 | */
222 |
223 | /**
224 | * @}
225 | */
226 |
227 | /**
228 | * @}
229 | */
230 |
231 | #endif /* I2C1 || I2C2 || I2C3 */
232 |
233 | /**
234 | * @}
235 | */
236 |
237 | #endif /* USE_FULL_LL_DRIVER */
238 |
239 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
240 |
--------------------------------------------------------------------------------
/Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_pwr.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32l0xx_ll_pwr.c
4 | * @author MCD Application Team
5 | * @brief PWR LL module driver.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright(c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | #if defined(USE_FULL_LL_DRIVER)
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "stm32l0xx_ll_pwr.h"
23 | #include "stm32l0xx_ll_bus.h"
24 |
25 | /** @addtogroup STM32L0xx_LL_Driver
26 | * @{
27 | */
28 |
29 | #if defined(PWR)
30 |
31 | /** @defgroup PWR_LL PWR
32 | * @{
33 | */
34 |
35 | /* Private types -------------------------------------------------------------*/
36 | /* Private variables ---------------------------------------------------------*/
37 | /* Private constants ---------------------------------------------------------*/
38 | /* Private macros ------------------------------------------------------------*/
39 | /* Private function prototypes -----------------------------------------------*/
40 |
41 | /* Exported functions --------------------------------------------------------*/
42 | /** @addtogroup PWR_LL_Exported_Functions
43 | * @{
44 | */
45 |
46 | /** @addtogroup PWR_LL_EF_Init
47 | * @{
48 | */
49 |
50 | /**
51 | * @brief De-initialize the PWR registers to their default reset values.
52 | * @retval An ErrorStatus enumeration value:
53 | * - SUCCESS: PWR registers are de-initialized
54 | * - ERROR: not applicable
55 | */
56 | ErrorStatus LL_PWR_DeInit(void)
57 | {
58 | /* Force reset of PWR clock */
59 | LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_PWR);
60 |
61 | /* Release reset of PWR clock */
62 | LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_PWR);
63 |
64 | return SUCCESS;
65 | }
66 |
67 | /**
68 | * @}
69 | */
70 |
71 | /**
72 | * @}
73 | */
74 |
75 | /**
76 | * @}
77 | */
78 | #endif /* defined(PWR) */
79 | /**
80 | * @}
81 | */
82 |
83 | #endif /* USE_FULL_LL_DRIVER */
84 |
85 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
86 |
--------------------------------------------------------------------------------
/Inc/adc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : ADC.h
4 | * Description : This file provides code for the configuration
5 | * of the ADC instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __adc_H
21 | #define __adc_H
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "main.h"
28 |
29 | /* USER CODE BEGIN Includes */
30 |
31 | /* USER CODE END Includes */
32 |
33 | /* USER CODE BEGIN Private defines */
34 |
35 | /* USER CODE END Private defines */
36 |
37 | void MX_ADC_Init(void);
38 |
39 | /* USER CODE BEGIN Prototypes */
40 |
41 | /* USER CODE END Prototypes */
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 | #endif /*__ adc_H */
47 |
48 | /**
49 | * @}
50 | */
51 |
52 | /**
53 | * @}
54 | */
55 |
56 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
57 |
--------------------------------------------------------------------------------
/Inc/gpio.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : gpio.h
4 | * Description : This file contains all the functions prototypes for
5 | * the gpio
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __gpio_H
22 | #define __gpio_H
23 | #ifdef __cplusplus
24 | extern "C" {
25 | #endif
26 |
27 | /* Includes ------------------------------------------------------------------*/
28 | #include "main.h"
29 |
30 | /* USER CODE BEGIN Includes */
31 |
32 | /* USER CODE END Includes */
33 |
34 | /* USER CODE BEGIN Private defines */
35 |
36 | /* USER CODE END Private defines */
37 |
38 | void MX_GPIO_Init(void);
39 |
40 | /* USER CODE BEGIN Prototypes */
41 |
42 | /* USER CODE END Prototypes */
43 |
44 | #ifdef __cplusplus
45 | }
46 | #endif
47 | #endif /*__ pinoutConfig_H */
48 |
49 | /**
50 | * @}
51 | */
52 |
53 | /**
54 | * @}
55 | */
56 |
57 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
58 |
--------------------------------------------------------------------------------
/Inc/i2c.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : I2C.h
4 | * Description : This file provides code for the configuration
5 | * of the I2C instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __i2c_H
21 | #define __i2c_H
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "main.h"
28 |
29 | /* USER CODE BEGIN Includes */
30 |
31 | /* USER CODE END Includes */
32 |
33 | /* USER CODE BEGIN Private defines */
34 |
35 | /* USER CODE END Private defines */
36 |
37 | void MX_I2C1_Init(void);
38 |
39 | /* USER CODE BEGIN Prototypes */
40 |
41 | /* USER CODE END Prototypes */
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 | #endif /*__ i2c_H */
47 |
48 | /**
49 | * @}
50 | */
51 |
52 | /**
53 | * @}
54 | */
55 |
56 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
57 |
--------------------------------------------------------------------------------
/Inc/lptim.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : LPTIM.h
4 | * Description : This file provides code for the configuration
5 | * of the LPTIM instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __lptim_H
21 | #define __lptim_H
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "main.h"
28 |
29 | /* USER CODE BEGIN Includes */
30 |
31 | /* USER CODE END Includes */
32 |
33 | /* USER CODE BEGIN Private defines */
34 |
35 | /* USER CODE END Private defines */
36 |
37 | void MX_LPTIM1_Init(void);
38 |
39 | /* USER CODE BEGIN Prototypes */
40 |
41 | /* USER CODE END Prototypes */
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 | #endif /*__ lptim_H */
47 |
48 | /**
49 | * @}
50 | */
51 |
52 | /**
53 | * @}
54 | */
55 |
56 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
57 |
--------------------------------------------------------------------------------
/Inc/main.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : main.h
5 | * @brief : Header for main.c file.
6 | * This file contains the common defines of the application.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2020 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __MAIN_H
24 | #define __MAIN_H
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "stm32l0xx_ll_adc.h"
32 | #include "stm32l0xx.h"
33 | #include "stm32l0xx_ll_i2c.h"
34 | #include "stm32l0xx_ll_lptim.h"
35 | #include "stm32l0xx_ll_crs.h"
36 | #include "stm32l0xx_ll_rcc.h"
37 | #include "stm32l0xx_ll_bus.h"
38 | #include "stm32l0xx_ll_system.h"
39 | #include "stm32l0xx_ll_exti.h"
40 | #include "stm32l0xx_ll_cortex.h"
41 | #include "stm32l0xx_ll_utils.h"
42 | #include "stm32l0xx_ll_pwr.h"
43 | #include "stm32l0xx_ll_dma.h"
44 | #include "stm32l0xx_ll_spi.h"
45 | #include "stm32l0xx_ll_tim.h"
46 | #include "stm32l0xx_ll_usart.h"
47 | #include "stm32l0xx_ll_gpio.h"
48 |
49 | #if defined(USE_FULL_ASSERT)
50 | #include "stm32_assert.h"
51 | #endif /* USE_FULL_ASSERT */
52 |
53 | /* Private includes ----------------------------------------------------------*/
54 | /* USER CODE BEGIN Includes */
55 |
56 | /* USER CODE END Includes */
57 |
58 | /* Exported types ------------------------------------------------------------*/
59 | /* USER CODE BEGIN ET */
60 |
61 | /* USER CODE END ET */
62 |
63 | /* Exported constants --------------------------------------------------------*/
64 | /* USER CODE BEGIN EC */
65 |
66 | /* USER CODE END EC */
67 |
68 | /* Exported macro ------------------------------------------------------------*/
69 | /* USER CODE BEGIN EM */
70 |
71 | /* USER CODE END EM */
72 |
73 | /* Exported functions prototypes ---------------------------------------------*/
74 | void Error_Handler(void);
75 |
76 | /* USER CODE BEGIN EFP */
77 |
78 | /* USER CODE END EFP */
79 |
80 | /* Private defines -----------------------------------------------------------*/
81 | #define BATTERY_ADC_IN1_Pin LL_GPIO_PIN_1
82 | #define BATTERY_ADC_IN1_GPIO_Port GPIOA
83 | #define BUZZER_TIM2_CH3_Pin LL_GPIO_PIN_2
84 | #define BUZZER_TIM2_CH3_GPIO_Port GPIOA
85 | #define EPD_DC_Pin LL_GPIO_PIN_3
86 | #define EPD_DC_GPIO_Port GPIOA
87 | #define EPD_RST_Pin LL_GPIO_PIN_4
88 | #define EPD_RST_GPIO_Port GPIOA
89 | #define EPD_SCK_Pin LL_GPIO_PIN_5
90 | #define EPD_SCK_GPIO_Port GPIOA
91 | #define EPD_CS_Pin LL_GPIO_PIN_6
92 | #define EPD_CS_GPIO_Port GPIOA
93 | #define EPD_MOSI_Pin LL_GPIO_PIN_7
94 | #define EPD_MOSI_GPIO_Port GPIOA
95 | #define EPD_BUSY_EXTI0_Pin LL_GPIO_PIN_0
96 | #define EPD_BUSY_EXTI0_GPIO_Port GPIOB
97 | #define EPD_POWER_Pin LL_GPIO_PIN_2
98 | #define EPD_POWER_GPIO_Port GPIOB
99 | #define LED_Pin LL_GPIO_PIN_8
100 | #define LED_GPIO_Port GPIOA
101 | #define SHT30_POWER_Pin LL_GPIO_PIN_11
102 | #define SHT30_POWER_GPIO_Port GPIOA
103 | #define SHT30_RST_Pin LL_GPIO_PIN_12
104 | #define SHT30_RST_GPIO_Port GPIOA
105 | #define BTN_SET_Pin LL_GPIO_PIN_15
106 | #define BTN_SET_GPIO_Port GPIOA
107 | #define BTN_UP_Pin LL_GPIO_PIN_3
108 | #define BTN_UP_GPIO_Port GPIOB
109 | #define BTN_DOWN_Pin LL_GPIO_PIN_4
110 | #define BTN_DOWN_GPIO_Port GPIOB
111 | #define I2C1_PULLUP_Pin LL_GPIO_PIN_5
112 | #define I2C1_PULLUP_GPIO_Port GPIOB
113 | #define DC_POWERSAVE_Pin LL_GPIO_PIN_8
114 | #define DC_POWERSAVE_GPIO_Port GPIOB
115 | #ifndef NVIC_PRIORITYGROUP_0
116 | #define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority,
117 | 4 bits for subpriority */
118 | #define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority,
119 | 3 bits for subpriority */
120 | #define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority,
121 | 2 bits for subpriority */
122 | #define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority,
123 | 1 bit for subpriority */
124 | #define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority,
125 | 0 bit for subpriority */
126 | #endif
127 | /* USER CODE BEGIN Private defines */
128 |
129 | /* USER CODE END Private defines */
130 |
131 | #ifdef __cplusplus
132 | }
133 | #endif
134 |
135 | #endif /* __MAIN_H */
136 |
137 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
138 |
--------------------------------------------------------------------------------
/Inc/spi.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : SPI.h
4 | * Description : This file provides code for the configuration
5 | * of the SPI instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __spi_H
21 | #define __spi_H
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "main.h"
28 |
29 | /* USER CODE BEGIN Includes */
30 |
31 | /* USER CODE END Includes */
32 |
33 | /* USER CODE BEGIN Private defines */
34 |
35 | /* USER CODE END Private defines */
36 |
37 | void MX_SPI1_Init(void);
38 |
39 | /* USER CODE BEGIN Prototypes */
40 |
41 | /* USER CODE END Prototypes */
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 | #endif /*__ spi_H */
47 |
48 | /**
49 | * @}
50 | */
51 |
52 | /**
53 | * @}
54 | */
55 |
56 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
57 |
--------------------------------------------------------------------------------
/Inc/stm32_assert.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32_assert.h
4 | * @brief STM32 assert file.
5 | ******************************************************************************
6 | * @attention
7 | *
8 | * © Copyright (c) 2018 STMicroelectronics.
9 | * All rights reserved.
10 | *
11 | * This software component is licensed by ST under BSD 3-Clause license,
12 | * the "License"; You may not use this file except in compliance with the
13 | * License. You may obtain a copy of the License at:
14 | * opensource.org/licenses/BSD-3-Clause
15 | *
16 | ******************************************************************************
17 | */
18 |
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __STM32_ASSERT_H
21 | #define __STM32_ASSERT_H
22 |
23 | #ifdef __cplusplus
24 | extern "C" {
25 | #endif
26 |
27 | /* Exported types ------------------------------------------------------------*/
28 | /* Exported constants --------------------------------------------------------*/
29 | /* Includes ------------------------------------------------------------------*/
30 | /* Exported macro ------------------------------------------------------------*/
31 | #ifdef USE_FULL_ASSERT
32 | /**
33 | * @brief The assert_param macro is used for function's parameters check.
34 | * @param expr: If expr is false, it calls assert_failed function
35 | * which reports the name of the source file and the source
36 | * line number of the call that failed.
37 | * If expr is true, it returns no value.
38 | * @retval None
39 | */
40 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
41 | /* Exported functions ------------------------------------------------------- */
42 | void assert_failed(uint8_t* file, uint32_t line);
43 | #else
44 | #define assert_param(expr) ((void)0U)
45 | #endif /* USE_FULL_ASSERT */
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif /* __STM32_ASSERT_H */
52 |
53 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
54 |
--------------------------------------------------------------------------------
/Inc/stm32l0xx_it.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32l0xx_it.h
5 | * @brief This file contains the headers of the interrupt handlers.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __STM32L0xx_IT_H
23 | #define __STM32L0xx_IT_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Private includes ----------------------------------------------------------*/
30 | /* USER CODE BEGIN Includes */
31 |
32 | /* USER CODE END Includes */
33 |
34 | /* Exported types ------------------------------------------------------------*/
35 | /* USER CODE BEGIN ET */
36 |
37 | /* USER CODE END ET */
38 |
39 | /* Exported constants --------------------------------------------------------*/
40 | /* USER CODE BEGIN EC */
41 |
42 | /* USER CODE END EC */
43 |
44 | /* Exported macro ------------------------------------------------------------*/
45 | /* USER CODE BEGIN EM */
46 |
47 | /* USER CODE END EM */
48 |
49 | /* Exported functions prototypes ---------------------------------------------*/
50 | void NMI_Handler(void);
51 | void HardFault_Handler(void);
52 | void SVC_Handler(void);
53 | void PendSV_Handler(void);
54 | void SysTick_Handler(void);
55 | /* USER CODE BEGIN EFP */
56 |
57 | /* USER CODE END EFP */
58 |
59 | #ifdef __cplusplus
60 | }
61 | #endif
62 |
63 | #endif /* __STM32L0xx_IT_H */
64 |
65 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
66 |
--------------------------------------------------------------------------------
/Inc/tim.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : TIM.h
4 | * Description : This file provides code for the configuration
5 | * of the TIM instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __tim_H
21 | #define __tim_H
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "main.h"
28 |
29 | /* USER CODE BEGIN Includes */
30 |
31 | /* USER CODE END Includes */
32 |
33 | /* USER CODE BEGIN Private defines */
34 |
35 | /* USER CODE END Private defines */
36 |
37 | void MX_TIM2_Init(void);
38 |
39 | /* USER CODE BEGIN Prototypes */
40 |
41 | /* USER CODE END Prototypes */
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 | #endif /*__ tim_H */
47 |
48 | /**
49 | * @}
50 | */
51 |
52 | /**
53 | * @}
54 | */
55 |
56 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
57 |
--------------------------------------------------------------------------------
/Inc/usart.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : USART.h
4 | * Description : This file provides code for the configuration
5 | * of the USART instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __usart_H
21 | #define __usart_H
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "main.h"
28 |
29 | /* USER CODE BEGIN Includes */
30 |
31 | /* USER CODE END Includes */
32 |
33 | /* USER CODE BEGIN Private defines */
34 |
35 | /* USER CODE END Private defines */
36 |
37 | void MX_USART1_UART_Init(void);
38 |
39 | /* USER CODE BEGIN Prototypes */
40 |
41 | /* USER CODE END Prototypes */
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 | #endif /*__ usart_H */
47 |
48 | /**
49 | * @}
50 | */
51 |
52 | /**
53 | * @}
54 | */
55 |
56 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
57 |
--------------------------------------------------------------------------------
/L051K8U6_EPD_CLOCK.ioc:
--------------------------------------------------------------------------------
1 | #MicroXplorer Configuration settings - do not modify
2 | ADC.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV2
3 | ADC.EOCSelection=ADC_EOC_SINGLE_CONV
4 | ADC.IPParameters=SamplingTime,EOCSelection,ClockPrescaler
5 | ADC.SamplingTime=ADC_SAMPLETIME_160CYCLES_5
6 | File.Version=6
7 | GPIO.groupedBy=Group By Peripherals
8 | I2C1.I2C_Coeff_DF=0
9 | I2C1.I2C_Fall_Time=30
10 | I2C1.I2C_Rise_Time=30
11 | I2C1.I2C_Speed_Mode=I2C_Fast
12 | I2C1.IPParameters=Timing,I2C_Speed_Mode,I2C_Rise_Time,I2C_Fall_Time,I2C_Coeff_DF
13 | I2C1.Timing=0x0010020B
14 | KeepUserPlacement=false
15 | LPTIM1.ClockPrescaler=LPTIM_PRESCALER_DIV16
16 | LPTIM1.IPParameters=ClockPrescaler
17 | Mcu.Family=STM32L0
18 | Mcu.IP0=ADC
19 | Mcu.IP1=I2C1
20 | Mcu.IP2=LPTIM1
21 | Mcu.IP3=NVIC
22 | Mcu.IP4=RCC
23 | Mcu.IP5=SPI1
24 | Mcu.IP6=SYS
25 | Mcu.IP7=TIM2
26 | Mcu.IP8=USART1
27 | Mcu.IPNb=9
28 | Mcu.Name=STM32L051K(6-8)Ux
29 | Mcu.Package=UFQFPN32
30 | Mcu.Pin0=PA0
31 | Mcu.Pin1=PA1
32 | Mcu.Pin10=PB2
33 | Mcu.Pin11=PA8
34 | Mcu.Pin12=PA9
35 | Mcu.Pin13=PA10
36 | Mcu.Pin14=PA11
37 | Mcu.Pin15=PA12
38 | Mcu.Pin16=PA13
39 | Mcu.Pin17=PA14
40 | Mcu.Pin18=PA15
41 | Mcu.Pin19=PB3
42 | Mcu.Pin2=PA2
43 | Mcu.Pin20=PB4
44 | Mcu.Pin21=PB5
45 | Mcu.Pin22=PB6
46 | Mcu.Pin23=PB7
47 | Mcu.Pin24=PB8
48 | Mcu.Pin25=VP_ADC_TempSens_Input
49 | Mcu.Pin26=VP_ADC_Vref_Input
50 | Mcu.Pin27=VP_LPTIM1_VS_LPTIM_counterModeInternalClock
51 | Mcu.Pin28=VP_SYS_VS_Systick
52 | Mcu.Pin29=VP_TIM2_VS_ClockSourceINT
53 | Mcu.Pin3=PA3
54 | Mcu.Pin4=PA4
55 | Mcu.Pin5=PA5
56 | Mcu.Pin6=PA6
57 | Mcu.Pin7=PA7
58 | Mcu.Pin8=PB0
59 | Mcu.Pin9=PB1
60 | Mcu.PinsNb=30
61 | Mcu.ThirdPartyNb=0
62 | Mcu.UserConstants=
63 | Mcu.UserName=STM32L051K8Ux
64 | MxCube.Version=6.0.1
65 | MxDb.Version=DB.6.0.0
66 | NVIC.ForceEnableDMAVector=true
67 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
68 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false
69 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false
70 | NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false
71 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
72 | PA0.Mode=SYS_WakeUp0
73 | PA0.Signal=SYS_WKUP1
74 | PA1.GPIOParameters=GPIO_Label
75 | PA1.GPIO_Label=BATTERY_ADC_IN1
76 | PA1.Locked=true
77 | PA1.Mode=IN1
78 | PA1.Signal=ADC_IN1
79 | PA10.Mode=Asynchronous
80 | PA10.Signal=USART1_RX
81 | PA11.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
82 | PA11.GPIO_Label=SHT30_POWER
83 | PA11.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
84 | PA11.GPIO_PuPd=GPIO_NOPULL
85 | PA11.Locked=true
86 | PA11.PinState=GPIO_PIN_SET
87 | PA11.Signal=GPIO_Output
88 | PA12.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
89 | PA12.GPIO_Label=SHT30_RST
90 | PA12.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
91 | PA12.GPIO_PuPd=GPIO_NOPULL
92 | PA12.Locked=true
93 | PA12.PinState=GPIO_PIN_RESET
94 | PA12.Signal=GPIO_Output
95 | PA13.Mode=Serial_Wire
96 | PA13.Signal=SYS_SWDIO
97 | PA14.Mode=Serial_Wire
98 | PA14.Signal=SYS_SWCLK
99 | PA15.GPIOParameters=GPIO_Label
100 | PA15.GPIO_Label=BTN_SET
101 | PA15.Locked=true
102 | PA15.Signal=GPIO_Input
103 | PA2.GPIOParameters=GPIO_Label
104 | PA2.GPIO_Label=BUZZER_TIM2_CH3
105 | PA2.Signal=S_TIM2_CH3
106 | PA3.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
107 | PA3.GPIO_Label=EPD_DC
108 | PA3.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
109 | PA3.GPIO_PuPd=GPIO_NOPULL
110 | PA3.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
111 | PA3.Locked=true
112 | PA3.PinState=GPIO_PIN_RESET
113 | PA3.Signal=GPIO_Output
114 | PA4.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
115 | PA4.GPIO_Label=EPD_RST
116 | PA4.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
117 | PA4.GPIO_PuPd=GPIO_NOPULL
118 | PA4.Locked=true
119 | PA4.PinState=GPIO_PIN_RESET
120 | PA4.Signal=GPIO_Output
121 | PA5.GPIOParameters=GPIO_Label
122 | PA5.GPIO_Label=EPD_SCK
123 | PA5.Locked=true
124 | PA5.Mode=TX_Only_Simplex_Unidirect_Master
125 | PA5.Signal=SPI1_SCK
126 | PA6.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
127 | PA6.GPIO_Label=EPD_CS
128 | PA6.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
129 | PA6.GPIO_PuPd=GPIO_NOPULL
130 | PA6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
131 | PA6.Locked=true
132 | PA6.PinState=GPIO_PIN_RESET
133 | PA6.Signal=GPIO_Output
134 | PA7.GPIOParameters=GPIO_Label
135 | PA7.GPIO_Label=EPD_MOSI
136 | PA7.Mode=TX_Only_Simplex_Unidirect_Master
137 | PA7.Signal=SPI1_MOSI
138 | PA8.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
139 | PA8.GPIO_Label=LED
140 | PA8.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
141 | PA8.GPIO_PuPd=GPIO_NOPULL
142 | PA8.Locked=true
143 | PA8.PinState=GPIO_PIN_SET
144 | PA8.Signal=GPIO_Output
145 | PA9.Mode=Asynchronous
146 | PA9.Signal=USART1_TX
147 | PB0.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
148 | PB0.GPIO_Label=EPD_BUSY_EXTI0
149 | PB0.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
150 | PB0.GPIO_PuPd=GPIO_PULLDOWN
151 | PB0.Locked=true
152 | PB0.Signal=GPXTI0
153 | PB1.Mode=VREFINT_ADC_PB1
154 | PB1.Signal=SYS_VREF_OUT_PB1
155 | PB2.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
156 | PB2.GPIO_Label=EPD_POWER
157 | PB2.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
158 | PB2.GPIO_PuPd=GPIO_NOPULL
159 | PB2.Locked=true
160 | PB2.PinState=GPIO_PIN_SET
161 | PB2.Signal=GPIO_Output
162 | PB3.GPIOParameters=GPIO_Label
163 | PB3.GPIO_Label=BTN_UP
164 | PB3.Locked=true
165 | PB3.Signal=GPIO_Input
166 | PB4.GPIOParameters=GPIO_Label
167 | PB4.GPIO_Label=BTN_DOWN
168 | PB4.Locked=true
169 | PB4.Signal=GPIO_Input
170 | PB5.GPIOParameters=PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
171 | PB5.GPIO_Label=I2C1_PULLUP
172 | PB5.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
173 | PB5.GPIO_PuPd=GPIO_NOPULL
174 | PB5.Locked=true
175 | PB5.PinState=GPIO_PIN_RESET
176 | PB5.Signal=GPIO_Output
177 | PB6.Locked=true
178 | PB6.Mode=I2C
179 | PB6.Signal=I2C1_SCL
180 | PB7.Mode=I2C
181 | PB7.Signal=I2C1_SDA
182 | PB8.GPIOParameters=PinState,GPIO_Label
183 | PB8.GPIO_Label=DC_POWERSAVE
184 | PB8.Locked=true
185 | PB8.PinState=GPIO_PIN_RESET
186 | PB8.Signal=GPIO_Output
187 | PinOutPanel.RotationAngle=0
188 | ProjectManager.AskForMigrate=true
189 | ProjectManager.BackupPrevious=false
190 | ProjectManager.CompilerOptimize=6
191 | ProjectManager.ComputerToolchain=false
192 | ProjectManager.CoupleFile=true
193 | ProjectManager.CustomerFirmwarePackage=
194 | ProjectManager.DefaultFWLocation=true
195 | ProjectManager.DeletePrevious=true
196 | ProjectManager.DeviceId=STM32L051K8Ux
197 | ProjectManager.FirmwarePackage=STM32Cube FW_L0 V1.11.3
198 | ProjectManager.FreePins=true
199 | ProjectManager.HalAssertFull=false
200 | ProjectManager.HeapSize=0x000
201 | ProjectManager.KeepUserCode=true
202 | ProjectManager.LastFirmware=true
203 | ProjectManager.LibraryCopy=1
204 | ProjectManager.MainLocation=Src
205 | ProjectManager.NoMain=false
206 | ProjectManager.PreviousToolchain=
207 | ProjectManager.ProjectBuild=false
208 | ProjectManager.ProjectFileName=L051K8U6_EPD_CLOCK.ioc
209 | ProjectManager.ProjectName=L051K8U6_EPD_CLOCK
210 | ProjectManager.RegisterCallBack=
211 | ProjectManager.StackSize=0x400
212 | ProjectManager.TargetToolchain=MDK-ARM V5.27
213 | ProjectManager.ToolChainLocation=
214 | ProjectManager.UnderRoot=false
215 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-LL-true,2-SystemClock_Config-RCC-false-LL-false,3-MX_ADC_Init-ADC-false-LL-true,4-MX_I2C1_Init-I2C1-false-LL-true,5-MX_SPI1_Init-SPI1-false-LL-true,6-MX_USART1_UART_Init-USART1-false-LL-true,7-MX_TIM2_Init-TIM2-false-LL-true,8-MX_LPTIM1_Init-LPTIM1-false-LL-true
216 | RCC.AHBCLKDivider=RCC_SYSCLK_DIV2
217 | RCC.AHBFreq_Value=8000000
218 | RCC.APB1Freq_Value=8000000
219 | RCC.APB1TimFreq_Value=8000000
220 | RCC.APB2Freq_Value=8000000
221 | RCC.APB2TimFreq_Value=8000000
222 | RCC.FCLKCortexFreq_Value=8000000
223 | RCC.FamilyName=M
224 | RCC.HCLKFreq_Value=8000000
225 | RCC.HSI16_VALUE=16000000
226 | RCC.HSI_VALUE=16000000
227 | RCC.I2C1Freq_Value=8000000
228 | RCC.IPParameters=AHBCLKDivider,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSI16_VALUE,HSI_VALUE,I2C1Freq_Value,LPTIMFreq_Value,LSE_VALUE,LSI_VALUE,LptimClockSelection,MCOPinFreq_Value,MSI_VALUE,PLLCLKFreq_Value,PREFETCH_ENABLE,PWRFreq_Value,RTCFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,TIMFreq_Value,TimerFreq_Value,USART1Freq_Value,USART2Freq_Value,VCOOutputFreq_Value,WatchDogFreq_Value
229 | RCC.LPTIMFreq_Value=37000
230 | RCC.LSE_VALUE=32768
231 | RCC.LSI_VALUE=37000
232 | RCC.LptimClockSelection=RCC_LPTIM1CLKSOURCE_LSI
233 | RCC.MCOPinFreq_Value=16000000
234 | RCC.MSI_VALUE=2097000
235 | RCC.PLLCLKFreq_Value=24000000
236 | RCC.PREFETCH_ENABLE=0
237 | RCC.PWRFreq_Value=16000000
238 | RCC.RTCFreq_Value=37000
239 | RCC.SYSCLKFreq_VALUE=16000000
240 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_HSI
241 | RCC.TIMFreq_Value=8000000
242 | RCC.TimerFreq_Value=8000000
243 | RCC.USART1Freq_Value=8000000
244 | RCC.USART2Freq_Value=8000000
245 | RCC.VCOOutputFreq_Value=48000000
246 | RCC.WatchDogFreq_Value=37000
247 | SH.GPXTI0.0=GPIO_EXTI0
248 | SH.GPXTI0.ConfNb=1
249 | SH.S_TIM2_CH3.0=TIM2_CH3,PWM Generation3 CH3
250 | SH.S_TIM2_CH3.ConfNb=1
251 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2
252 | SPI1.CLKPhase=SPI_PHASE_2EDGE
253 | SPI1.CLKPolarity=SPI_POLARITY_HIGH
254 | SPI1.CalculateBaudRate=4.0 MBits/s
255 | SPI1.Direction=SPI_DIRECTION_2LINES
256 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,CLKPhase,CLKPolarity
257 | SPI1.Mode=SPI_MODE_MASTER
258 | SPI1.VirtualType=VM_MASTER
259 | TIM2.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
260 | TIM2.IPParameters=Channel-PWM Generation3 CH3,Prescaler,Period,Pulse-PWM Generation3 CH3,OCPolarity_3
261 | TIM2.OCPolarity_3=TIM_OCPOLARITY_LOW
262 | TIM2.Period=249
263 | TIM2.Prescaler=7
264 | TIM2.Pulse-PWM\ Generation3\ CH3=124
265 | USART1.IPParameters=VirtualMode-Asynchronous
266 | USART1.VirtualMode-Asynchronous=VM_ASYNC
267 | VP_ADC_TempSens_Input.Mode=IN-TempSens
268 | VP_ADC_TempSens_Input.Signal=ADC_TempSens_Input
269 | VP_ADC_Vref_Input.Mode=IN-Vrefint
270 | VP_ADC_Vref_Input.Signal=ADC_Vref_Input
271 | VP_LPTIM1_VS_LPTIM_counterModeInternalClock.Mode=Counts__internal_clock_event_00
272 | VP_LPTIM1_VS_LPTIM_counterModeInternalClock.Signal=LPTIM1_VS_LPTIM_counterModeInternalClock
273 | VP_SYS_VS_Systick.Mode=SysTick
274 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick
275 | VP_TIM2_VS_ClockSourceINT.Mode=Internal
276 | VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
277 | board=custom
278 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
25 |
--------------------------------------------------------------------------------
/MDK-ARM/DebugConfig/L051K8U6_EPD_CLOCK_STM32L051K8Ux.dbgconf:
--------------------------------------------------------------------------------
1 | // File: STM32L0x1_0x2_0x3_DBGMCU.ini
2 | // Version: 1.0.0
3 | // Note: refer to STM32L0x1 reference manual (RM0377)
4 | // refer to STM32L0x1 datasheet
5 | // refer to STM32L0x2 reference manual (RM0376)
6 | // refer to STM32L0x2 datasheet
7 | // refer to STM32L0x3 reference manual (RM0367)
8 | // refer to STM32L0x3 datasheet
9 |
10 | // <<< Use Configuration Wizard in Context Menu >>>
11 |
12 | // Debug MCU configuration register (DBGMCU_CR)
13 | // Reserved bits must be kept at reset value
14 | // DBG_STANDBY Debug Standby Mode
15 | // DBG_STOP Debug Stop Mode
16 | // DBG_SLEEP Debug Sleep Mode
17 | //
18 | DbgMCU_CR = 0x00000007;
19 |
20 | // Debug MCU APB1 freeze register (DBGMCU_APB1_FZ)
21 | // Reserved bits must be kept at reset value
22 | // DBG_LPTIMER_STOP LPTIM1 counter stopped when core is halted
23 | // DBG_I2C3_STOP I2C3 SMBUS timeout mode stopped when core is halted
24 | // DBG_I2C2_STOP I2C2 SMBUS timeout mode stopped when core is halted
25 | // DBG_I2C1_STOP I2C1 SMBUS timeout mode stopped when core is halted
26 | // DBG_IWDG_STOP Debug independent watchdog stopped when core is halted
27 | // DBG_WWDG_STOP Debug window watchdog stopped when core is halted
28 | // DBG_RTC_STOP Debug RTC stopped when core is halted
29 | // DBG_TIM7_STOP TIM7 counter stopped when core is halted
30 | // DBG_TIM6_STOP TIM6 counter stopped when core is halted
31 | // DBG_TIM3_STOP TIM3 counter stopped when core is halted
32 | // DBG_TIM2_STOP TIM2 counter stopped when core is halted
33 | //
34 | DbgMCU_APB1_Fz = 0x00000000;
35 |
36 | // Debug MCU APB2 freeze register (DBGMCU_APB2_FZ)
37 | // Reserved bits must be kept at reset value
38 | // DBG_TIM22_STOP TIM22 counter stopped when core is halted
39 | // DBG_TIM21_STOP TIM21 counter stopped when core is halted
40 | //
41 | DbgMCU_APB2_Fz = 0x00000000;
42 |
43 | // Flash Download Options
44 | // Option Byte Loading Launch the Option Byte Loading after a Flash Download by setting the OBL_LAUNCH bit (causes a reset)
45 | //
46 | DoOptionByteLoading = 0x00000000;
47 |
48 | // <<< end of configuration section >>>
49 |
--------------------------------------------------------------------------------
/MDK-ARM/RTE/_L051K8U6_EPD_CLOCK/RTE_Components.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Auto generated Run-Time-Environment Configuration File
4 | * *** Do not modify ! ***
5 | *
6 | * Project: 'L051K8U6_EPD_CLOCK'
7 | * Target: 'L051K8U6_EPD_CLOCK'
8 | */
9 |
10 | #ifndef RTE_COMPONENTS_H
11 | #define RTE_COMPONENTS_H
12 |
13 |
14 | /*
15 | * Define the Device Header File:
16 | */
17 | #define CMSIS_device_header "stm32l0xx.h"
18 |
19 |
20 |
21 | #endif /* RTE_COMPONENTS_H */
22 |
--------------------------------------------------------------------------------
/Src/USER/analog.h:
--------------------------------------------------------------------------------
1 | #ifndef _ANALOG_H_
2 | #define _ANALOG_H_
3 |
4 | #include "main.h"
5 |
6 | /* 可修改 */
7 | #define ADC_NUM ADC1
8 | #define ADC_CHANNEL_BATTERY LL_ADC_CHANNEL_1
9 | #define ADC_VREFINT_OUT_PIN LL_SYSCFG_VREFINT_CONNECT_IO2
10 | /* 结束 */
11 |
12 | #define ADC_TIMEOUT_MS 1000
13 |
14 | uint8_t ADC_Enable(void);
15 | uint8_t ADC_Disable(void);
16 | uint8_t ADC_StartCal(void);
17 | uint8_t ADC_GetCalFactor(void);
18 | uint8_t ADC_StartConversionSequence(uint32_t channels, uint16_t *data, uint8_t data_size);
19 |
20 | float ADC_GetTemp(void);
21 | float ADC_GetVDDA(void);
22 | float ADC_GetChannel(uint32_t channel);
23 | void ADC_EnableVrefintOutput(void);
24 | void ADC_DisableVrefintOutput(void);
25 |
26 | float ADC_GetVrefintFactory(void);
27 | float ADC_GetVrefintStep(void);
28 | void ADC_SetVrefintOffset(int16_t offset);
29 | int16_t ADC_GetVrefintOffset(void);
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/Src/USER/bkpr.c:
--------------------------------------------------------------------------------
1 | #include "bkpr.h"
2 |
3 | /**
4 | * @brief 从指定地址读取一字节。
5 | * @param addr 备份寄存器地址,对于20Byte容量的寄存器,起始地址为0,最大地址为19。
6 | * @return 读取到的数据
7 | */
8 | uint8_t BKPR_ReadByte(uint8_t addr)
9 | {
10 | uint32_t dword_temp;
11 |
12 | dword_temp = *(__IO uint32_t *)(RTC_BACKUPREG_BASEADDR + ((addr / 4) * 4));
13 | return (dword_temp >> ((addr % 4) * 8)) & 0x000000FF;
14 | }
15 |
16 | /**
17 | * @brief 向指定地址写入一字节。
18 | * @param addr 备份寄存器地址,对于20Byte容量的寄存器,起始地址为0,最大地址为19。
19 | * @param data 要写入的数据。
20 | * @return 1:写入错误,0:写入完成。
21 | */
22 | uint8_t BKPR_WriteByte(uint8_t addr, uint8_t data)
23 | {
24 | uint8_t offset;
25 | uint32_t align_addr, dword_temp;
26 |
27 | align_addr = (addr / 4) * 4;
28 | offset = (addr % 4) * 8;
29 | dword_temp = *(__IO uint32_t *)(RTC_BACKUPREG_BASEADDR + align_addr);
30 | dword_temp &= ~(0x000000FF << offset);
31 | dword_temp |= (uint32_t)data << offset;
32 | if (LL_PWR_IsEnabledBkUpAccess() == 0)
33 | {
34 | LL_PWR_EnableBkUpAccess();
35 | }
36 | *(__IO uint32_t *)(RTC_BACKUPREG_BASEADDR + align_addr) = dword_temp;
37 | LL_PWR_DisableBkUpAccess();
38 | if (BKPR_ReadByte(addr) != data)
39 | {
40 | return 1;
41 | }
42 | return 0;
43 | }
44 |
45 | /**
46 | * @brief 从指定地址读取两字节。
47 | * @param addr 备份寄存器地址,对于20Byte容量的寄存器,起始地址为0,最大地址为9。
48 | * @return 读取到的数据
49 | */
50 | uint16_t BKPR_ReadWORD(uint8_t addr)
51 | {
52 | uint32_t dword_temp;
53 |
54 | dword_temp = *(__IO uint32_t *)(RTC_BACKUPREG_BASEADDR + ((addr / 2) * 4));
55 | return (dword_temp >> ((addr % 2) * 16)) & 0x0000FFFF;
56 | }
57 |
58 | /**
59 | * @brief 向指定地址写入两字节。
60 | * @param addr 备份寄存器地址,对于20Byte容量的寄存器,起始地址为0,最大地址为9。
61 | * @param data 要写入的数据。
62 | * @return 1:写入错误,0:写入完成。
63 | */
64 | uint8_t BKPR_WriteWORD(uint8_t addr, uint16_t data)
65 | {
66 | uint8_t offset;
67 | uint32_t align_addr, dword_temp;
68 |
69 | align_addr = (addr / 2) * 4;
70 | offset = (addr % 2) * 16;
71 | dword_temp = *(__IO uint32_t *)(RTC_BACKUPREG_BASEADDR + align_addr);
72 | dword_temp &= ~(0x0000FFFF << offset);
73 | dword_temp |= (uint32_t)data << offset;
74 | if (LL_PWR_IsEnabledBkUpAccess() == 0)
75 | {
76 | LL_PWR_EnableBkUpAccess();
77 | }
78 | *(__IO uint32_t *)(RTC_BACKUPREG_BASEADDR + align_addr) = dword_temp;
79 | LL_PWR_DisableBkUpAccess();
80 | if (BKPR_ReadWORD(addr) != data)
81 | {
82 | return 1;
83 | }
84 | return 0;
85 | }
86 |
87 | /**
88 | * @brief 从指定地址读取四字节。
89 | * @param addr 备份寄存器地址,对于20Byte容量的寄存器,起始地址为0,最大地址为4。
90 | * @return 读取到的数据
91 | */
92 | uint32_t BKPR_ReadDWORD(uint8_t addr)
93 | {
94 | return *(__IO uint32_t *)(RTC_BACKUPREG_BASEADDR + (addr * 4));
95 | }
96 |
97 | /**
98 | * @brief 向指定地址写入四字节。
99 | * @param addr 备份寄存器地址,对于20Byte容量的寄存器,起始地址为0,最大地址为4。
100 | * @param data 要写入的数据。
101 | * @return 1:写入错误,0:写入完成。
102 | */
103 | uint8_t BKPR_WriteDWORD(uint8_t addr, uint32_t data)
104 | {
105 | if (LL_PWR_IsEnabledBkUpAccess() == 0)
106 | {
107 | LL_PWR_EnableBkUpAccess();
108 | }
109 | *(__IO uint32_t *)(RTC_BACKUPREG_BASEADDR + (addr * 4)) = data;
110 | LL_PWR_DisableBkUpAccess();
111 | if (BKPR_ReadDWORD(addr) != data)
112 | {
113 | return 1;
114 | }
115 | return 0;
116 | }
117 |
118 | /**
119 | * @brief 重置备份寄存器,清除所有数据。
120 | * @return 1:复位失败,0:复位完成。
121 | */
122 | uint8_t BKPR_ResetAll(void)
123 | {
124 | uint8_t i;
125 |
126 | if (LL_PWR_IsEnabledBkUpAccess() == 0)
127 | {
128 | LL_PWR_EnableBkUpAccess();
129 | }
130 | LL_RCC_ForceBackupDomainReset();
131 | LL_RCC_ReleaseBackupDomainReset();
132 | LL_PWR_DisableBkUpAccess();
133 | for (i = 0; i < 5; i++)
134 | {
135 | if (BKPR_ReadDWORD(i) != 0)
136 | {
137 | return 1;
138 | }
139 | }
140 | return 0;
141 | }
142 |
--------------------------------------------------------------------------------
/Src/USER/bkpr.h:
--------------------------------------------------------------------------------
1 | #ifndef _BKPR_H_
2 | #define _BKPR_H_
3 |
4 | #include "main.h"
5 |
6 | /* 可修改 */
7 | #define RTC_BACKUPREG_BASEADDR 0x40002850 /* 0x40002800 + 0x50 = 0x40002850 */
8 | /* 结束 */
9 |
10 | uint8_t BKPR_ReadByte(uint8_t addr);
11 | uint16_t BKPR_ReadWORD(uint8_t addr);
12 | uint32_t BKPR_ReadDWORD(uint8_t addr);
13 |
14 | uint8_t BKPR_WriteByte(uint8_t addr, uint8_t data);
15 | uint8_t BKPR_WriteWORD(uint8_t addr, uint16_t data);
16 | uint8_t BKPR_WriteDWORD(uint8_t addr, uint32_t data);
17 |
18 | uint8_t BKPR_ResetAll(void);
19 |
20 | #endif
21 |
--------------------------------------------------------------------------------
/Src/USER/buzzer.c:
--------------------------------------------------------------------------------
1 | #include "buzzer.h"
2 | #include
3 |
4 | /**
5 | * @brief 打开蜂鸣器定时器。
6 | */
7 | void BUZZER_Enable(void)
8 | {
9 | LL_TIM_CC_DisableChannel(BUZZER_TIMER, BUZZER_CHANNEL);
10 | LL_TIM_SetCounter(BUZZER_TIMER, LL_TIM_GetAutoReload(BUZZER_TIMER) / 2);
11 | LL_TIM_EnableCounter(BUZZER_TIMER);
12 | }
13 |
14 | /**
15 | * @brief 关闭蜂鸣器定时器。
16 | */
17 | void BUZZER_Disable(void)
18 | {
19 | LL_TIM_CC_DisableChannel(BUZZER_TIMER, BUZZER_CHANNEL);
20 | LL_TIM_DisableCounter(BUZZER_TIMER);
21 | }
22 |
23 | /**
24 | * @brief 设置蜂鸣器频率。
25 | * @param freq 蜂鸣器频率。
26 | */
27 | void BUZZER_SetFrqe(uint32_t freq)
28 | {
29 | uint32_t autoreload;
30 |
31 | if (freq > BUZZER_CLOCK)
32 | {
33 | autoreload = 1;
34 | }
35 | else
36 | {
37 | autoreload = (BUZZER_CLOCK / freq) - 1;
38 | if (autoreload > 0xFFFF)
39 | {
40 | autoreload = 1;
41 | }
42 | }
43 | LL_TIM_SetAutoReload(BUZZER_TIMER, autoreload);
44 | if (LL_TIM_GetCounter(BUZZER_TIMER) > autoreload)
45 | {
46 | LL_TIM_SetCounter(BUZZER_TIMER, 0);
47 | }
48 | }
49 |
50 | /**
51 | * @brief 设置蜂鸣器音量。
52 | * @param vol 蜂鸣器音量,范围为:0 ~ 10。
53 | */
54 | void BUZZER_SetVolume(uint8_t vol)
55 | {
56 | uint32_t autoreload;
57 |
58 | autoreload = LL_TIM_GetAutoReload(BUZZER_TIMER);
59 | vol = vol % 11;
60 | BUZZER_OC_SET_FUNC(BUZZER_TIMER, ((autoreload / 2.0) / 100) * pow(vol, 2.0));
61 | }
62 |
63 | /**
64 | * @brief 蜂鸣器响一声。
65 | * @param time_ms 持续时间。
66 | */
67 | void BUZZER_Beep(uint16_t time_ms)
68 | {
69 | if (time_ms != 0)
70 | {
71 | LL_TIM_SetCounter(BUZZER_TIMER, LL_TIM_GetAutoReload(BUZZER_TIMER) / 2);
72 | LL_TIM_CC_EnableChannel(BUZZER_TIMER, BUZZER_CHANNEL);
73 | }
74 | LL_mDelay(time_ms);
75 | LL_TIM_CC_DisableChannel(BUZZER_TIMER, BUZZER_CHANNEL);
76 | }
77 |
78 | /**
79 | * @brief 打开蜂鸣器,在关闭前持续鸣响。
80 | */
81 | void BUZZER_Start(void)
82 | {
83 | LL_TIM_SetCounter(BUZZER_TIMER, LL_TIM_GetAutoReload(BUZZER_TIMER) / 2);
84 | LL_TIM_CC_EnableChannel(BUZZER_TIMER, BUZZER_CHANNEL);
85 | }
86 |
87 | /**
88 | * @brief 关闭蜂鸣器,停止鸣响。
89 | */
90 | void BUZZER_Stop(void)
91 | {
92 | LL_TIM_CC_DisableChannel(BUZZER_TIMER, BUZZER_CHANNEL);
93 | }
94 |
--------------------------------------------------------------------------------
/Src/USER/buzzer.h:
--------------------------------------------------------------------------------
1 | #ifndef _BUZZER_H_
2 | #define _BUZZER_H_
3 |
4 | #include "main.h"
5 |
6 | /* 可修改 */
7 | #define BUZZER_TIMER TIM2
8 | #define BUZZER_CHANNEL LL_TIM_CHANNEL_CH3
9 | #define BUZZER_OC_SET_FUNC LL_TIM_OC_SetCompareCH3
10 | #define BUZZER_CLOCK 1000000
11 | /* 结束 */
12 |
13 | #define BUZZER_MAX_VOL 10
14 |
15 | void BUZZER_Enable(void);
16 | void BUZZER_Disable(void);
17 | void BUZZER_Start(void);
18 | void BUZZER_Stop(void);
19 | void BUZZER_Beep(uint16_t time_ms);
20 | void BUZZER_SetVolume(uint8_t vol);
21 | void BUZZER_SetFrqe(uint32_t freq);
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/Src/USER/ds3231.h:
--------------------------------------------------------------------------------
1 | #ifndef _DS3231_H_
2 | #define _DS3231_H_
3 |
4 | #include "main.h"
5 | #include "iic.h"
6 |
7 | /* 可修改 */
8 | #define RTC_I2C_ADDR ((0x68 & 0xFE) << 1)
9 | /* 结束 */
10 |
11 | #define RTC_REG_SEC 0x00
12 | #define RTC_REG_MIN 0x01
13 | #define RTC_REG_HOR 0x02
14 | #define RTC_REG_DAY 0x03
15 | #define RTC_REG_DAT 0x04
16 | #define RTC_REG_MON 0x05
17 | #define RTC_REG_YER 0x06
18 |
19 | #define RTC_REG_AL1_SEC 0x07
20 | #define RTC_REG_AL1_MIN 0x08
21 | #define RTC_REG_AL1_HOR 0x09
22 | #define RTC_REG_AL1_DDT 0x0A
23 |
24 | #define RTC_REG_AL2_MIN 0x0B
25 | #define RTC_REG_AL2_HOR 0x0C
26 | #define RTC_REG_AL2_DDT 0x0D
27 |
28 | #define RTC_REG_CTL 0x0E
29 | #define RTC_REG_STA 0x0F
30 | #define RTC_REG_AGI 0x10
31 | #define RTC_REG_TPM 0x11
32 | #define RTC_REG_TPL 0x12
33 |
34 | struct RTC_Time
35 | {
36 | uint8_t Seconds;
37 | uint8_t Minutes;
38 | uint8_t Hours;
39 | uint8_t Day;
40 | uint8_t Date;
41 | uint8_t Month;
42 | uint8_t Year;
43 | uint8_t PM;
44 | uint8_t Is_12hr;
45 | };
46 |
47 | struct RTC_Alarm
48 | {
49 | uint8_t Seconds;
50 | uint8_t Minutes;
51 | uint8_t Hours;
52 | uint8_t Day;
53 | uint8_t Date;
54 | uint8_t DY;
55 | uint8_t PM;
56 | uint8_t Is_12hr;
57 | };
58 |
59 | uint8_t RTC_ReadREG(uint8_t reg);
60 | uint8_t RTC_WriteREG(uint8_t reg, uint8_t data);
61 | uint8_t RTC_ReadREG_Multi(uint8_t start_reg, uint8_t read_size, uint8_t *read_data);
62 | uint8_t RTC_WriteREG_Multi(uint8_t start_reg, uint8_t write_size, const uint8_t *write_data);
63 | uint8_t RTC_ModifyREG(uint8_t reg, uint8_t mask, uint8_t new_val);
64 | uint8_t RTC_TestREG(uint8_t reg, uint8_t mask);
65 |
66 | uint8_t RTC_GetTime(struct RTC_Time *time);
67 | uint8_t RTC_SetTime(const struct RTC_Time *time);
68 | void RTC_CheckTimeRange(struct RTC_Time *time);
69 |
70 | uint8_t RTC_GetAlarm1(struct RTC_Alarm *alarm);
71 | uint8_t RTC_SetAlarm1(const struct RTC_Alarm *alarm);
72 | uint8_t RTC_GetAlarm2(struct RTC_Alarm *alarm);
73 | uint8_t RTC_SetAlarm2(const struct RTC_Alarm *alarm);
74 |
75 | uint8_t RTC_GetAM1Mask(void);
76 | uint8_t RTC_ModifyAM1Mask(uint8_t alarm_mask);
77 | uint8_t RTC_GetAM2Mask(void);
78 | uint8_t RTC_ModifyAM2Mask(uint8_t alarm_mask);
79 | uint8_t RTC_GetEOSC(void);
80 | uint8_t RTC_ModifyEOSC(uint8_t eosc);
81 | uint8_t RTC_GetBBSQW(void);
82 | uint8_t RTC_ModifyBBSQW(uint8_t bbsqw);
83 | uint8_t RTC_GetCONV(void);
84 | uint8_t RTC_ModifyCONV(uint8_t conv);
85 | uint8_t RTC_GetRS(void);
86 | uint8_t RTC_ModifyRS(uint8_t rs);
87 | uint8_t RTC_GetINTCN(void);
88 | uint8_t RTC_ModifyINTCN(uint8_t intcn);
89 | uint8_t RTC_GetA2IE(void);
90 | uint8_t RTC_ModifyA2IE(uint8_t a2ie);
91 | uint8_t RTC_GetA1IE(void);
92 | uint8_t RTC_ModifyA1IE(uint8_t a1ie);
93 | uint8_t RTC_GetOSF(void);
94 | uint8_t RTC_ClearOSF(void);
95 | uint8_t RTC_GetEN32KHZ(void);
96 | uint8_t RTC_ModifyEN32KHZ(uint8_t en32khz);
97 | uint8_t RTC_GetBUSY(void);
98 | uint8_t RTC_GetA2F(void);
99 | uint8_t RTC_ClearA2F(void);
100 | uint8_t RTC_GetA1F(void);
101 | uint8_t RTC_ClearA1F(void);
102 | int8_t RTC_GetAging(void);
103 | uint8_t RTC_ModifyAging(int8_t aging);
104 | float RTC_GetTemp(void);
105 | uint8_t RTC_ResetAllRegToDefault(void);
106 |
107 | #endif
108 |
--------------------------------------------------------------------------------
/Src/USER/eeprom.c:
--------------------------------------------------------------------------------
1 | #include "eeprom.h"
2 |
3 | #define EEPROM_UNLOCK() \
4 | if (eeprom_unlock() != 0) \
5 | { \
6 | return 1; \
7 | }
8 |
9 | #define EEPROM_LOCK() \
10 | if (eeprom_lock() != 0) \
11 | { \
12 | return 1; \
13 | }
14 |
15 | /**
16 | * @brief 等待EEPROM空闲。
17 | * @return 1:等待超时,0:EEPROM空闲。
18 | */
19 | static uint8_t eeprom_wait_busy(void)
20 | {
21 | uint32_t timeout;
22 | volatile uint32_t systick_tmp;
23 |
24 | timeout = EEPROM_TIMEOUT_MS;
25 | systick_tmp = SysTick->CTRL;
26 | ((void)systick_tmp);
27 | while (timeout != 0 && (FLASH->SR & FLASH_SR_BSY) != 0)
28 | {
29 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
30 | {
31 | timeout -= 1;
32 | }
33 | }
34 | if (timeout == 0)
35 | {
36 | return 1;
37 | }
38 | return 0;
39 | }
40 |
41 | /**
42 | * @brief 解锁EEPROM。
43 | * @return 1:解锁错误,0:解锁完成。
44 | */
45 | static uint8_t eeprom_unlock(void)
46 | {
47 | if (eeprom_wait_busy() != 0)
48 | {
49 | return 1;
50 | }
51 | if ((FLASH->PECR & FLASH_PECR_PELOCK) == 1)
52 | {
53 | FLASH->PEKEYR = EEPROM_UNLOCK_KEY1;
54 | FLASH->PEKEYR = EEPROM_UNLOCK_KEY2;
55 | }
56 | return 0;
57 | }
58 |
59 | /**
60 | * @brief 锁定EEPROM。
61 | * @return 1:锁定错误,0:锁定完成。
62 | */
63 | static uint8_t eeprom_lock(void)
64 | {
65 | if (eeprom_wait_busy() != 0)
66 | {
67 | return 1;
68 | }
69 | FLASH->PECR |= FLASH_PECR_PELOCK;
70 | if ((FLASH->PECR & FLASH_PECR_PELOCK) == 0)
71 | {
72 | return 1;
73 | }
74 | return 0;
75 | }
76 |
77 | /**
78 | * @brief 从指定地址读取一字节。
79 | * @param addr EEPROM地址,对于2K存储容量的EEPROM,起始地址为0,最大地址为2047。
80 | * @return 读取到的数据。
81 | */
82 | uint8_t EEPROM_ReadByte(uint16_t addr)
83 | {
84 | return *(__IO uint8_t *)(EEPROM_BASE_ADDR + addr);
85 | }
86 |
87 | /**
88 | * @brief 向指定地址写入一字节。
89 | * @param addr EEPROM地址,对于2K存储容量的EEPROM,起始地址为0,最大地址为2047。
90 | * @param data 要写入的数据。
91 | * @return 1:写入错误,0:写入完成。
92 | */
93 | uint8_t EEPROM_WriteByte(uint16_t addr, uint8_t data)
94 | {
95 | EEPROM_UNLOCK();
96 | *(__IO uint8_t *)(EEPROM_BASE_ADDR + addr) = data;
97 | EEPROM_LOCK();
98 | if (*(__IO uint8_t *)(EEPROM_BASE_ADDR + addr) != data)
99 | {
100 | return 1;
101 | }
102 | return 0;
103 | }
104 |
105 | /**
106 | * @brief 从指定地址读取两字节。
107 | * @param addr EEPROM地址,对于2K存储容量的EEPROM,起始地址为0,最大地址为1023。
108 | * @return 读取到的数据。
109 | */
110 | uint16_t EEPROM_ReadWORD(uint16_t addr)
111 | {
112 | addr *= 2;
113 | return *(__IO uint16_t *)(EEPROM_BASE_ADDR + addr);
114 | }
115 |
116 | /**
117 | * @brief 向指定地址写入两字节。
118 | * @param addr EEPROM地址,对于2K存储容量的EEPROM,起始地址为0,最大地址为1023。
119 | * @param data 要写入的数据。
120 | * @return 1:写入错误,0:写入完成。
121 | */
122 | uint8_t EEPROM_WriteWORD(uint16_t addr, uint16_t data)
123 | {
124 | addr *= 2;
125 | EEPROM_UNLOCK();
126 | *(__IO uint16_t *)(EEPROM_BASE_ADDR + addr) = data;
127 | EEPROM_LOCK();
128 | if (*(__IO uint16_t *)(EEPROM_BASE_ADDR + addr) != data)
129 | {
130 | return 1;
131 | }
132 | return 0;
133 | }
134 |
135 | /**
136 | * @brief 从指定地址读取四字节。
137 | * @param addr EEPROM地址,对于2K存储容量的EEPROM,起始地址为0,最大地址为511。
138 | * @return 读取到的数据。
139 | */
140 | uint32_t EEPROM_ReadDWORD(uint16_t addr)
141 | {
142 | addr *= 4;
143 | return *(__IO uint32_t *)(EEPROM_BASE_ADDR + addr);
144 | }
145 |
146 | /**
147 | * @brief 向指定地址写入四字节。
148 | * @param addr EEPROM地址,对于2K存储容量的EEPROM,起始地址为0,最大地址为511。
149 | * @param data 要写入的数据。
150 | * @return 1:写入错误,0:写入完成。
151 | */
152 | uint8_t EEPROM_WriteDWORD(uint16_t addr, uint32_t data)
153 | {
154 | addr *= 4;
155 | EEPROM_UNLOCK();
156 | *(__IO uint32_t *)(EEPROM_BASE_ADDR + addr) = data;
157 | EEPROM_LOCK();
158 | if (*(__IO uint32_t *)(EEPROM_BASE_ADDR + addr) != data)
159 | {
160 | return 1;
161 | }
162 | return 0;
163 | }
164 |
165 | /**
166 | * @brief 擦除指定地址的一字节。
167 | * @param addr EEPROM地址,对于2K存储容量的EEPROM,起始地址为0,最大地址为2047。
168 | * @return 1:擦除错误,0:擦除完成。
169 | * @note 内置EEPROM不需要先擦除再写入,可以直接写入数据。
170 | * @note 在擦除时的内部执行顺序为:读取四字节->擦除四字节->将目标地址的数据清零->写入四字节,这样会造成写入放大,可能会有损EEPROM寿命。
171 | */
172 | uint8_t EEPROM_EraseByte(uint16_t addr)
173 | {
174 | uint16_t align_addr;
175 | uint32_t word_buffer;
176 |
177 | align_addr = (addr / 4) * 4;
178 | word_buffer = *(__IO uint32_t *)(EEPROM_BASE_ADDR + align_addr);
179 | EEPROM_UNLOCK();
180 | FLASH->PECR |= FLASH_PECR_ERASE | FLASH_PECR_DATA;
181 | *(__IO uint32_t *)(EEPROM_BASE_ADDR + align_addr) = 0;
182 | eeprom_wait_busy();
183 | FLASH->PECR &= ~(FLASH_PECR_ERASE | FLASH_PECR_DATA);
184 | word_buffer &= ~(0x000000FF << ((addr % 4) * 8));
185 | *(__IO uint32_t *)(EEPROM_BASE_ADDR + align_addr) = word_buffer;
186 | EEPROM_LOCK();
187 | if (*(__IO uint32_t *)(EEPROM_BASE_ADDR + align_addr) != word_buffer)
188 | {
189 | return 1;
190 | }
191 | return 0;
192 | }
193 |
194 | /**
195 | * @brief 擦除指定地址的两字节。
196 | * @param addr EEPROM地址,对于2K存储容量的EEPROM,起始地址为0,最大地址为1023。
197 | * @return 1:擦除错误,0:擦除完成。
198 | * @note 内置EEPROM不需要先擦除再写入,可以直接写入数据。
199 | * @note 在擦除时的内部执行顺序为:读取四字节->擦除四字节->将目标地址的数据清零->写入四字节,这样会造成写入放大,可能会有损EEPROM寿命。
200 | */
201 | uint8_t EEPROM_EraseWORD(uint16_t addr)
202 | {
203 | uint16_t align_addr;
204 | uint32_t word_buffer;
205 |
206 | addr *= 2;
207 | align_addr = (addr / 4) * 4;
208 | word_buffer = *(__IO uint32_t *)(EEPROM_BASE_ADDR + align_addr);
209 | EEPROM_UNLOCK();
210 | FLASH->PECR |= FLASH_PECR_ERASE | FLASH_PECR_DATA;
211 | *(__IO uint32_t *)(EEPROM_BASE_ADDR + align_addr) = 0;
212 | eeprom_wait_busy();
213 | FLASH->PECR &= ~(FLASH_PECR_ERASE | FLASH_PECR_DATA);
214 | word_buffer &= ~(0x0000FFFF << (((addr / 2) % 2) * 16));
215 | *(__IO uint32_t *)(EEPROM_BASE_ADDR + align_addr) = word_buffer;
216 | EEPROM_LOCK();
217 | if (*(__IO uint32_t *)(EEPROM_BASE_ADDR + align_addr) != word_buffer)
218 | {
219 | return 1;
220 | }
221 | return 0;
222 | }
223 |
224 | /**
225 | * @brief 擦除指定地址的四字节。
226 | * @param addr EEPROM地址,对于2K存储容量的EEPROM,起始地址为0,最大地址为511。
227 | * @return 1:擦除错误,0:擦除完成。
228 | * @note 内置EEPROM不需要先擦除再写入,可以直接写入数据。
229 | */
230 | uint8_t EEPROM_EraseDWORD(uint16_t addr)
231 | {
232 | addr *= 4;
233 | EEPROM_UNLOCK();
234 | FLASH->PECR |= FLASH_PECR_ERASE | FLASH_PECR_DATA;
235 | *(__IO uint32_t *)(EEPROM_BASE_ADDR + addr) = 0;
236 | eeprom_wait_busy();
237 | FLASH->PECR &= ~(FLASH_PECR_ERASE | FLASH_PECR_DATA);
238 | EEPROM_LOCK();
239 | if (*(__IO uint32_t *)(EEPROM_BASE_ADDR + addr) != 0)
240 | {
241 | return 1;
242 | }
243 | return 0;
244 | }
245 |
246 | /**
247 | * @brief 以四字节为单位,擦除指定地址范围内的数据。
248 | * @param addr EEPROM地址,对于2K存储容量的EEPROM,起始地址为0,最大地址为511。
249 | * @return 大于0:擦除时出错的循环次数,减1为出错的地址,0:擦除完成。
250 | * @note 内置EEPROM不需要先擦除再写入,可以直接写入数据。
251 | */
252 | uint16_t EEPROM_EraseRange(uint16_t start_addr_DWORD, uint16_t end_addr_DWORD)
253 | {
254 | uint8_t err;
255 | uint16_t i;
256 |
257 | EEPROM_UNLOCK();
258 | FLASH->PECR |= FLASH_PECR_ERASE | FLASH_PECR_DATA;
259 | err = 0;
260 | end_addr_DWORD += 1;
261 | for (i = start_addr_DWORD; i < end_addr_DWORD; i++)
262 | {
263 | *(__IO uint32_t *)(EEPROM_BASE_ADDR + (i * 4)) = 0;
264 | if (eeprom_wait_busy() != 0 || *(__IO uint32_t *)(EEPROM_BASE_ADDR + (i * 4)) != 0)
265 | {
266 | err = 1;
267 | break;
268 | }
269 | }
270 | FLASH->PECR &= ~(FLASH_PECR_ERASE | FLASH_PECR_DATA);
271 | EEPROM_LOCK();
272 | if (err != 0)
273 | {
274 | return i + 1;
275 | }
276 | return 0;
277 | }
278 |
--------------------------------------------------------------------------------
/Src/USER/eeprom.h:
--------------------------------------------------------------------------------
1 | #ifndef _EEPROM_H_
2 | #define _EEPROM_H_
3 |
4 | #include "main.h"
5 |
6 | /* 可修改 */
7 | #define EEPROM_UNLOCK_KEY1 0x89ABCDEF
8 | #define EEPROM_UNLOCK_KEY2 0x02030405
9 | #define EEPROM_BASE_ADDR 0x08080000
10 | /* 结束 */
11 |
12 | #define EEPROM_TIMEOUT_MS 1000
13 |
14 | uint8_t EEPROM_ReadByte(uint16_t addr);
15 | uint16_t EEPROM_ReadWORD(uint16_t addr);
16 | uint32_t EEPROM_ReadDWORD(uint16_t addr);
17 |
18 | uint8_t EEPROM_WriteByte(uint16_t addr, uint8_t data);
19 | uint8_t EEPROM_WriteWORD(uint16_t addr, uint16_t data);
20 | uint8_t EEPROM_WriteDWORD(uint16_t addr, uint32_t data);
21 |
22 | uint8_t EEPROM_EraseByte(uint16_t addr);
23 | uint8_t EEPROM_EraseWORD(uint16_t addr);
24 | uint8_t EEPROM_EraseDWORD(uint16_t addr);
25 | uint16_t EEPROM_EraseRange(uint16_t start_addr_DWORD, uint16_t end_addr_DWORD);
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/Src/USER/func.h:
--------------------------------------------------------------------------------
1 | #ifndef _FUNC_H_
2 | #define _FUNC_H_
3 |
4 | #include "main.h"
5 |
6 | #include "lowpower.h"
7 | #include "analog.h"
8 | #include "bkpr.h"
9 | #include "eeprom.h"
10 | #include "serial.h"
11 | #include "iic.h"
12 | #include "ds3231.h"
13 | #include "sht30.h"
14 | #include "gdeh029A1.h"
15 | #include "buzzer.h"
16 | #include "lunar.h"
17 |
18 | /* 可修改 */
19 | #define SOFT_VERSION "L051_1.06_MELANTHA"
20 | #define BTN_DEBOUNCE_MS 24
21 | #define BAT_MIN_VOLTAGE 0.80
22 | #define BAT_MAX_VOLTAGE 3.00
23 | /* 结束 */
24 |
25 | #define BKPR_ADDR_DWORD_ADCVAL 0x00
26 | #define BKPR_ADDR_BYTE_REQINIT 0x04
27 |
28 | #define EEPROM_ADDR_BYTE_SETTING 0x00
29 | #define EEPROM_ADDR_DWORD_HWVERSION 0x01FF
30 |
31 | #define REQUEST_RESET_ALL_FLAG 0x55
32 | #define SETTING_AVALIABLE_FLAG 0xAA
33 |
34 | struct Func_Setting
35 | {
36 | uint8_t available;
37 | uint8_t buzzer_enable;
38 | uint8_t buzzer_volume;
39 | float battery_warn;
40 | float battery_stop;
41 | float sensor_temp_offset;
42 | float sensor_rh_offset;
43 | int16_t vrefint_offset;
44 | int8_t rtc_aging_offset;
45 | };
46 |
47 | void Init(void);
48 | void Loop(void);
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/Src/USER/iic.c:
--------------------------------------------------------------------------------
1 | #include "iic.h"
2 |
3 | #define WAIT_TIMEOUT(val) \
4 | timeout = I2C_TIMEOUT_MS; \
5 | systick_tmp = SysTick->CTRL; \
6 | ((void)systick_tmp); \
7 | while (timeout != 0 && val) \
8 | { \
9 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U) \
10 | { \
11 | timeout -= 1; \
12 | } \
13 | } \
14 | if (timeout == 0) \
15 | { \
16 | if (i2c_reset() == 0) \
17 | { \
18 | return 1; \
19 | } \
20 | else \
21 | { \
22 | return 2; \
23 | } \
24 | }
25 |
26 | /**
27 | * @brief 延时100ns的倍数(不准确,只是大概)。
28 | * @param nsX100 延时时间。
29 | */
30 | static void delay_100ns(volatile uint16_t nsX100)
31 | {
32 | while (nsX100)
33 | {
34 | nsX100--;
35 | }
36 | ((void)nsX100);
37 | }
38 |
39 | /**
40 | * @brief 尝试清除I2C死锁状态。
41 | * @return 1:未成功清除死锁,0:已成功清除死锁。
42 | */
43 | static uint8_t i2c_reset(void)
44 | {
45 | uint32_t timeout;
46 | volatile uint32_t systick_tmp;
47 | uint32_t i2c_old_state;
48 |
49 | i2c_old_state = LL_I2C_IsEnabled(I2C_NUM); /* 保存I2C复位前的启用状态 */
50 | LL_I2C_Disable(I2C_NUM); /* 软复位 */
51 | for (timeout = 0; timeout < 10; timeout++) /* 等待软复位 */
52 | {
53 | if (LL_I2C_IsEnabled(I2C_NUM) == 0)
54 | {
55 | break;
56 | }
57 | }
58 | LL_I2C_DeInit(I2C_NUM); /* 释放I2C */
59 |
60 | /* 切换数据IO到开漏输出 */
61 | LL_GPIO_SetPinMode(I2C_SDA_PORT, I2C_SDA_PIN, LL_GPIO_MODE_OUTPUT);
62 | LL_GPIO_SetPinOutputType(I2C_SDA_PORT, I2C_SDA_PIN, LL_GPIO_OUTPUT_OPENDRAIN);
63 | LL_GPIO_SetPinPull(I2C_SDA_PORT, I2C_SDA_PIN, LL_GPIO_PULL_UP);
64 |
65 | /* 切换时钟IO到开漏输出 */
66 | LL_GPIO_SetPinMode(I2C_SCL_PORT, I2C_SCL_PIN, LL_GPIO_MODE_OUTPUT);
67 | LL_GPIO_SetPinOutputType(I2C_SCL_PORT, I2C_SCL_PIN, LL_GPIO_OUTPUT_OPENDRAIN);
68 | LL_GPIO_SetPinPull(I2C_SCL_PORT, I2C_SCL_PIN, LL_GPIO_PULL_UP);
69 |
70 | /* 设置IO默认状态 */
71 | LL_GPIO_SetOutputPin(I2C_SDA_PORT, I2C_SDA_PIN);
72 | LL_GPIO_SetOutputPin(I2C_SCL_PORT, I2C_SCL_PIN);
73 | delay_100ns(100);
74 |
75 | if (LL_GPIO_IsInputPinSet(I2C_SDA_PORT, I2C_SDA_PIN) == 0) /* 检测I2C是否已释放,如未释放则代表I2C未恢复,继续处理 */
76 | {
77 | timeout = I2C_TIMEOUT_MS;
78 | systick_tmp = SysTick->CTRL;
79 | ((void)systick_tmp);
80 | while (timeout != 0) /* 在时钟线上发送脉冲,用来跳过现有数据 */
81 | {
82 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
83 | {
84 | timeout -= 1;
85 | }
86 | LL_GPIO_ResetOutputPin(I2C_SCL_PORT, I2C_SCL_PIN);
87 | delay_100ns(100);
88 | LL_GPIO_SetOutputPin(I2C_SCL_PORT, I2C_SCL_PIN);
89 | delay_100ns(100);
90 | if (LL_GPIO_IsInputPinSet(I2C_SDA_PORT, I2C_SDA_PIN) != 0) /* 数据线为高 */
91 | {
92 | timeout = 0xFFFFFFFF; /* I2C数据线已被释放 */
93 | break;
94 | }
95 | }
96 | LL_GPIO_ResetOutputPin(I2C_SDA_PORT, I2C_SDA_PIN); /* 不管数据线是否为高,都发送一次停止和结束标志 */
97 | LL_mDelay(0);
98 | LL_GPIO_SetOutputPin(I2C_SDA_PORT, I2C_SDA_PIN);
99 | LL_mDelay(0);
100 | }
101 | else
102 | {
103 | timeout = 0xFFFFFFFF; /* I2C数据线已被释放 */
104 | }
105 |
106 | I2C_INIT_FUNC(); /* 不管有没有成功恢复,都重新初始化I2C */
107 | if (i2c_old_state != 0) /* 恢复I2C启用状态 */
108 | {
109 | LL_I2C_Enable(I2C_NUM);
110 | }
111 | if (timeout != 0xFFFFFFFF)
112 | {
113 | return 1;
114 | }
115 | return 0;
116 | }
117 |
118 | /**
119 | * @brief 产生启动或重新启动标志,开始数据传输。
120 | * @param addr I2C设备地址。
121 | * @param is_read 本次传输是读取数据,不是写入数据。
122 | * @param data_size 要传输的数据大小。
123 | * @return 3:发送开始传输信号后收到了NACK,2:I2C从机未响应或发生死锁,未恢复,1:I2C从机未响应或发生死锁,已恢复,可以重新执行,0:传输已启动。
124 | */
125 | uint8_t I2C_Start(uint8_t addr, uint8_t is_read, uint8_t data_size)
126 | {
127 | uint32_t timeout;
128 | volatile uint32_t systick_tmp;
129 |
130 | if (LL_I2C_IsActiveFlag_BUSY(I2C_NUM) != 0)
131 | {
132 | timeout = I2C_TIMEOUT_MS;
133 | systick_tmp = SysTick->CTRL;
134 | ((void)systick_tmp);
135 | while (timeout != 0 && LL_I2C_IsActiveFlag_TXE(I2C_NUM) == 0)
136 | {
137 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
138 | {
139 | timeout -= 1;
140 | }
141 | }
142 | if (timeout == 0)
143 | {
144 | if (i2c_reset() == 0)
145 | {
146 | return 1;
147 | }
148 | else
149 | {
150 | return 2;
151 | }
152 | }
153 | }
154 | /* DocID025942 Rev 8 - Page 604 */
155 | LL_I2C_SetMasterAddressingMode(I2C_NUM, LL_I2C_ADDRESSING_MODE_7BIT);
156 | LL_I2C_SetSlaveAddr(I2C_NUM, addr);
157 | if (is_read == 0)
158 | {
159 | LL_I2C_SetTransferRequest(I2C_NUM, LL_I2C_REQUEST_WRITE);
160 | }
161 | else
162 | {
163 | LL_I2C_SetTransferRequest(I2C_NUM, LL_I2C_REQUEST_READ);
164 | }
165 | LL_I2C_DisableReloadMode(I2C_NUM);
166 | LL_I2C_SetTransferSize(I2C_NUM, data_size);
167 | /* DocID025942 Rev 8 - Page 606 */
168 | LL_I2C_DisableAutoEndMode(I2C_NUM);
169 | LL_I2C_GenerateStartCondition(I2C_NUM);
170 | timeout = I2C_TIMEOUT_MS;
171 | systick_tmp = SysTick->CTRL;
172 | ((void)systick_tmp);
173 | if (is_read == 0)
174 | {
175 | while (timeout != 0 && LL_I2C_IsActiveFlag_TXE(I2C_NUM) == 0)
176 | {
177 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
178 | {
179 | timeout -= 1;
180 | }
181 | if (LL_I2C_IsActiveFlag_NACK(I2C_NUM) != 0)
182 | {
183 | LL_I2C_ClearFlag_NACK(I2C_NUM);
184 | return 3;
185 | }
186 | }
187 | }
188 | else
189 | {
190 | while (timeout != 0 && LL_I2C_IsActiveFlag_RXNE(I2C_NUM) == 0)
191 | {
192 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
193 | {
194 | timeout -= 1;
195 | }
196 | if (LL_I2C_IsActiveFlag_NACK(I2C_NUM) != 0)
197 | {
198 | LL_I2C_ClearFlag_NACK(I2C_NUM);
199 | return 3;
200 | }
201 | }
202 | }
203 | if (timeout == 0)
204 | {
205 | if (i2c_reset() == 0)
206 | {
207 | return 1;
208 | }
209 | else
210 | {
211 | return 2;
212 | }
213 | }
214 | return 0;
215 | }
216 |
217 | /**
218 | * @brief 产生停止标志。
219 | * @return 2:I2C从机未响应或发生死锁,未恢复,1:I2C从机未响应或发生死锁,已恢复,可以重新执行,0:传输已停止。
220 | */
221 | uint8_t I2C_Stop(void)
222 | {
223 | uint32_t timeout;
224 | volatile uint32_t systick_tmp;
225 |
226 | timeout = I2C_TIMEOUT_MS;
227 | systick_tmp = SysTick->CTRL;
228 | ((void)systick_tmp);
229 | while (timeout != 0 && LL_I2C_IsActiveFlag_TXE(I2C_NUM) == 0)
230 | {
231 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
232 | {
233 | timeout -= 1;
234 | }
235 | }
236 | if (timeout == 0)
237 | {
238 | if (i2c_reset() == 0)
239 | {
240 | return 1;
241 | }
242 | else
243 | {
244 | return 2;
245 | }
246 | }
247 | LL_I2C_GenerateStopCondition(I2C_NUM);
248 | timeout = I2C_TIMEOUT_MS;
249 | systick_tmp = SysTick->CTRL;
250 | ((void)systick_tmp);
251 | while (timeout != 0 && LL_I2C_IsActiveFlag_BUSY(I2C_NUM) != 0)
252 | {
253 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
254 | {
255 | timeout -= 1;
256 | }
257 | }
258 | if (timeout == 0)
259 | {
260 | if (i2c_reset() != 0)
261 | {
262 | return 2;
263 | }
264 | else
265 | {
266 | return 1;
267 | }
268 | }
269 | return 0;
270 | }
271 |
272 | /**
273 | * @brief 发送一字节。
274 | * @param byte 要传输的数据。
275 | * @return 2:I2C从机未响应或发生死锁,未恢复,1:I2C从机未响应或发生死锁,需要重新执行,0:数据已发送。
276 | */
277 | uint8_t I2C_WriteByte(uint8_t byte)
278 | {
279 | uint32_t timeout;
280 | volatile uint32_t systick_tmp;
281 |
282 | timeout = I2C_TIMEOUT_MS;
283 | systick_tmp = SysTick->CTRL;
284 | ((void)systick_tmp);
285 | while (timeout != 0 && LL_I2C_IsActiveFlag_TXE(I2C_NUM) == 0)
286 | {
287 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
288 | {
289 | timeout -= 1;
290 | }
291 | }
292 | if (timeout == 0)
293 | {
294 | if (i2c_reset() != 0)
295 | {
296 | return 2;
297 | }
298 | else
299 | {
300 | return 1;
301 | }
302 | }
303 | LL_I2C_TransmitData8(I2C_NUM, byte);
304 | return 0;
305 | }
306 |
307 | /**
308 | * @brief 接收一字节。
309 | * @return 接收到的数据。
310 | */
311 | uint8_t I2C_ReadByte(void)
312 | {
313 | uint32_t timeout;
314 | volatile uint32_t systick_tmp;
315 |
316 | timeout = I2C_TIMEOUT_MS;
317 | systick_tmp = SysTick->CTRL;
318 | ((void)systick_tmp);
319 | while (timeout != 0 && LL_I2C_IsActiveFlag_RXNE(I2C_NUM) == 0)
320 | {
321 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
322 | {
323 | timeout -= 1;
324 | }
325 | }
326 | if (timeout == 0)
327 | {
328 | i2c_reset();
329 | return 0x00;
330 | }
331 | return LL_I2C_ReceiveData8(I2C_NUM);
332 | }
333 |
--------------------------------------------------------------------------------
/Src/USER/iic.h:
--------------------------------------------------------------------------------
1 | #ifndef _IIC_H_
2 | #define _IIC_H_
3 |
4 | #include "main.h"
5 | #include "i2c.h"
6 |
7 | /* 可修改 */
8 | #define I2C_NUM I2C1
9 | #define I2C_PULLUP_PORT I2C1_PULLUP_GPIO_Port
10 | #define I2C_PULLUP_PIN I2C1_PULLUP_Pin
11 | #define I2C_SCL_PORT GPIOB
12 | #define I2C_SCL_PIN LL_GPIO_PIN_6
13 | #define I2C_SDA_PORT GPIOB
14 | #define I2C_SDA_PIN LL_GPIO_PIN_7
15 | #define I2C_INIT_FUNC MX_I2C1_Init
16 | /* 结束 */
17 |
18 | #define I2C_TIMEOUT_MS 1000
19 |
20 | uint8_t I2C_Start(uint8_t addr, uint8_t is_read, uint8_t data_size);
21 | uint8_t I2C_Stop(void);
22 | uint8_t I2C_WriteByte(uint8_t byte);
23 | uint8_t I2C_ReadByte(void);
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/Src/USER/lowpower.c:
--------------------------------------------------------------------------------
1 | #include "lowpower.h"
2 |
3 | /**
4 | * @brief 开启唤醒外部中断。
5 | */
6 | static void wkup_exti_init(void)
7 | {
8 | LL_EXTI_DisableIT_0_31(LP_WKUP_EXTI); /* 关闭外部中断 */
9 | LL_EXTI_ClearFlag_0_31(LP_WKUP_EXTI); /* 清除中断标志 */
10 | NVIC_ClearPendingIRQ(LP_WKUP_IRQ); /* 清除待处理中断 */
11 | LL_EXTI_EnableIT_0_31(LP_WKUP_EXTI); /* 打开外部中断 */
12 | NVIC_EnableIRQ(LP_WKUP_IRQ); /* 打开中断请求 */
13 | NVIC_SetPriority(LP_WKUP_IRQ, 0); /* 设置中断请求优先级 */
14 | }
15 |
16 | /**
17 | * @brief 关闭唤醒外部中断。
18 | */
19 | static void wkup_exti_deinit(void)
20 | {
21 | NVIC_DisableIRQ(LP_WKUP_IRQ); /* 关闭中断请求 */
22 | LL_EXTI_DisableIT_0_31(LP_WKUP_EXTI); /* 关闭外部中断 */
23 | LL_EXTI_ClearFlag_0_31(LP_WKUP_EXTI); /* 清除中断标志 */
24 | NVIC_ClearPendingIRQ(LP_WKUP_IRQ); /* 清除待处理中断 */
25 | }
26 |
27 | /**
28 | * @brief 低功耗定时器初始化。
29 | * @param ms 定时时间,单位为毫秒
30 | */
31 | static void lptim_init(uint16_t ms)
32 | {
33 | if (LL_LPTIM_IsEnabled(LP_LPTIM_NUM) == 0) /* 确保已打开低功耗定时器 */
34 | {
35 | LL_LPTIM_Enable(LP_LPTIM_NUM);
36 | }
37 | LL_LPTIM_SetAutoReload(LP_LPTIM_NUM, (ms / (1000 / LP_LPTIM_FINAL_CLK)) + 0.5); /* 设置重载数值 */
38 | LL_LPTIM_EnableIT_ARRM(LP_LPTIM_NUM); /* 打开重载数值匹配中断 */
39 | LL_EXTI_EnableIT_0_31(LP_LPTIM_EXTI); /* 打开外部中断 */
40 | NVIC_EnableIRQ(LP_LPTIM_WKUP_IRQ); /* 打开中断请求 */
41 | NVIC_SetPriority(LP_LPTIM_WKUP_IRQ, 0); /* 设置中断请求优先级 */
42 | LL_LPTIM_StartCounter(LP_LPTIM_NUM, LL_LPTIM_OPERATING_MODE_ONESHOT); /* 开始计数 */
43 | }
44 |
45 | /**
46 | * @brief 低功耗定时器关闭。
47 | */
48 | static void lptim_deinit(void)
49 | {
50 | NVIC_DisableIRQ(LP_LPTIM_WKUP_IRQ); /* 关闭中断请求 */
51 | LL_LPTIM_DisableIT_ARRM(LP_LPTIM_NUM); /* 关闭重载数值匹配中断 */
52 | LL_LPTIM_ClearFLAG_ARRM(LP_LPTIM_NUM); /* 清除中断标志 */
53 | LL_EXTI_ClearFlag_0_31(LP_LPTIM_EXTI); /* 清除中断标志 */
54 | NVIC_ClearPendingIRQ(LP_LPTIM_WKUP_IRQ); /* 清除待处理中断 */
55 | LL_LPTIM_Disable(LP_LPTIM_NUM); /* 关闭低功耗定时器 */
56 | }
57 |
58 | /**
59 | * @brief 手动禁用调试,防止Keil下载完成后不进行断电重启的话会造成电流异常消耗(使用STM32 ST-LINK Utility下载无此问题)。
60 | */
61 | void LP_DisableDebug(void)
62 | {
63 | RCC->APB2ENR |= RCC_APB2ENR_DBGMCUEN; /* __HAL_RCC_DBGMCU_CLK_ENABLE(); */
64 | DBGMCU->CR &= ~(DBGMCU_CR_DBG_SLEEP | DBGMCU_CR_DBG_STOP | DBGMCU_CR_DBG_STANDBY); /* HAL_DBGMCU_DisableDBGSleepMode(); ... */
65 | RCC->APB2ENR &= ~RCC_APB2ENR_DBGMCUEN; /* __HAL_RCC_DBGMCU_CLK_DISABLE(); */
66 | LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_13, LL_GPIO_MODE_ANALOG); /* 将调试IO设置为模拟输入 */
67 | LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_14, LL_GPIO_MODE_ANALOG); /* 将调试IO设置为模拟输入 */
68 | LL_GPIO_SetPinPull(GPIOA, LL_GPIO_PIN_13, LL_GPIO_PULL_NO); /* 关闭调试IO内部上下拉电阻 */
69 | LL_GPIO_SetPinPull(GPIOA, LL_GPIO_PIN_14, LL_GPIO_PULL_NO); /* 关闭调试IO内部上下拉电阻 */
70 | }
71 |
72 | /**
73 | * @brief 获取系统复位类型。
74 | * @return LP_RESET_NORMALRESET:普通复位(nRST按键复位、看门狗复位...),LP_RESET_POWERON:上电复位(电源连接,安装电池...),LP_RESET_WKUPSTANDBY:从Standby模式唤醒。
75 | * @note 获取后将清除标志,无法获取第二次。
76 | */
77 | uint8_t LP_GetResetInfo(void)
78 | {
79 | uint8_t ret;
80 |
81 | if (LL_RCC_IsActiveFlag_PORRST() != 0) /* 上电复位 */
82 | {
83 | ret = LP_RESET_POWERON;
84 | }
85 | else if ((RCC->CSR & 0xFF000000) != 0) /* 所有普通复位,如果需要可以继续细分 */
86 | {
87 | ret = LP_RESET_NORMALRESET;
88 | }
89 | else if (LL_PWR_IsActiveFlag_SB() != 0) /* 从Standby模式唤醒 */
90 | {
91 | ret = LP_RESET_WKUPSTANDBY;
92 | }
93 | else /* 没有复位产生 */
94 | {
95 | ret = 0;
96 | }
97 | LL_PWR_ClearFlag_SB(); /* 清除从Standby模式唤醒标志 */
98 | LL_RCC_ClearResetFlags(); /* 清除普通复位标志 */
99 | return ret;
100 | }
101 |
102 | /**
103 | * @brief 进入Sleep模式,等待中断唤醒。
104 | * @param ms 超时时间,0为永不超时,每增加1超时时间大约增加1毫秒。
105 | * @note 进入后所有IO状态保持不变。
106 | * @note 唤醒最快,电力消耗较多。
107 | * @note 唤醒后程序从停止位置继续执行。
108 | */
109 | void LP_EnterSleep(uint16_t ms)
110 | {
111 | uint32_t voltage_scale;
112 |
113 | __disable_irq(); /* 暂停响应所有中断 */
114 |
115 | wkup_exti_init();
116 | if (ms != 0)
117 | {
118 | lptim_init(ms); /* 初始化低功耗定时器 */
119 | }
120 |
121 | voltage_scale = LL_PWR_GetRegulVoltageScaling();
122 | LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE2); /* 设置Vcore电压等级到二级,CPU最高允许8Mhz */
123 | LL_LPM_EnableSleep(); /* 准备进入Sleep模式 */
124 | LL_FLASH_EnableSleepPowerDown(); /* 进入Sleep模式后,关闭Flash电源,减小电流消耗 */
125 | __WFI(); /* 进入Sleep模式,等待唤醒引脚唤醒 */
126 | LL_PWR_SetRegulVoltageScaling(voltage_scale); /* 恢复Vcore电压等级 */
127 |
128 | wkup_exti_deinit();
129 | if (ms != 0)
130 | {
131 | lptim_deinit(); /* 关闭低功耗定时器 */
132 | }
133 |
134 | __enable_irq(); /* 重新响应所有中断 */
135 | }
136 |
137 | /**
138 | * @brief 进入Stop模式,等待中断唤醒,进入前需确保I2C没有数据传输或暂时关闭I2C,详见 dm00114897 第16页 2.5.1。
139 | * @param ms 超时时间,0为永不超时,每增加1超时时间大约增加1毫秒。
140 | * @note 进入后所有IO状态保持不变。
141 | * @note 唤醒较快,电力消耗较少。
142 | * @note 唤醒后程序从停止位置继续执行。
143 | */
144 | void LP_EnterStop(uint16_t ms)
145 | {
146 | uint32_t voltage_scale;
147 |
148 | __disable_irq(); /* 暂停响应所有中断 */
149 |
150 | LL_PWR_DisableWakeUpPin(LP_STANDBY_WKUP_PIN); /* 禁用Standby唤醒引脚 */
151 | LL_PWR_ClearFlag_WU(); /* 清除Standby唤醒标志 */
152 | wkup_exti_init();
153 | if (ms != 0)
154 | {
155 | lptim_init(ms); /* 初始化低功耗定时器 */
156 | }
157 |
158 | voltage_scale = LL_PWR_GetRegulVoltageScaling();
159 | LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE2); /* 设置Vcore电压等级到二级,CPU最高允许8Mhz */
160 | LL_PWR_EnableUltraLowPower(); /* 进入低功耗模式后,关闭VREFINT */
161 | LL_PWR_DisableFastWakeUp(); /* 唤醒后等待VREFINT恢复 */
162 | LL_RCC_SetClkAfterWakeFromStop(LL_RCC_STOP_WAKEUPCLOCK_HSI); /* 设置唤醒后的系统时钟源为HSI16,默认唤醒后为MSI */
163 | LL_PWR_SetRegulModeLP(LL_PWR_REGU_LPMODES_LOW_POWER); /* 设置进入低功耗模式后,稳压器为低功耗模式 */
164 | LL_PWR_SetPowerMode(LL_PWR_MODE_STOP); /* 设置DeepSleep为Stop模式 */
165 | LL_LPM_EnableDeepSleep(); /* 准备进入Stop模式 */
166 | __WFI(); /* 进入Stop模式,等待中断唤醒 */
167 | LL_PWR_SetRegulVoltageScaling(voltage_scale); /* 恢复Vcore电压等级 */
168 |
169 | wkup_exti_deinit();
170 | LL_PWR_DisableUltraLowPower(); /* 恢复电源配置 */
171 | if (ms != 0)
172 | {
173 | lptim_deinit(); /* 关闭低功耗定时器 */
174 | }
175 |
176 | __enable_irq(); /* 重新响应所有中断 */
177 | }
178 |
179 | /**
180 | * @brief 进入Standby模式,等待WKUP引脚或复位唤醒。
181 | * @note 进入后除唤醒IO以外的IO均自动变为高阻状态。
182 | * @note 唤醒最慢,电力消耗最少。
183 | * @note 唤醒后类似按键复位,程序重头开始执行。
184 | */
185 | void LP_EnterStandby(void)
186 | {
187 | __disable_irq(); /* 暂停响应所有中断 */
188 |
189 | LL_PWR_DisableWakeUpPin(LP_STANDBY_WKUP_PIN); /* 禁用Standby唤醒引脚 */
190 | LL_PWR_ClearFlag_WU(); /* 清除Standby唤醒标志 */
191 | LL_PWR_ClearFlag_SB(); /* 清除Standby唤醒标志 */
192 | LL_PWR_EnableWakeUpPin(LP_STANDBY_WKUP_PIN); /* 启用Standby唤醒引脚 */
193 |
194 | LL_RCC_DisableRTC(); /* 关闭实时时钟 */
195 | LL_RCC_LSI_Disable(); /* 关闭37kHz振荡器 */
196 | LL_RCC_LSE_Disable(); /* 关闭外部低速振荡器 */
197 |
198 | LL_PWR_EnableUltraLowPower(); /* 进入低功耗模式后,关闭VREFINT */
199 | LL_PWR_SetPowerMode(LL_PWR_MODE_STANDBY); /* 设置DeepSleep为Standby模式 */
200 | LL_LPM_EnableDeepSleep(); /* 准备进入Standby模式 */
201 | __WFI(); /* 进入Standby模式,等待唤醒引脚唤醒 */
202 | }
203 |
204 | /**
205 | * @brief 进入Sleep模式并等待一段时间后退出。
206 | * @param ms 延时时间,每增加1时间增加LP_LPTIM_AUTORELOAD_MS。
207 | * @note 进入后所有IO状态保持不变。
208 | * @note 唤醒最快,电力消耗较多。
209 | * @note 唤醒后程序从停止位置继续执行。
210 | */
211 | void LP_DelayStop(uint16_t ms)
212 | {
213 | uint32_t voltage_scale;
214 |
215 | if (ms == 0)
216 | {
217 | return;
218 | }
219 | __disable_irq(); /* 暂停响应所有中断 */
220 |
221 | LL_PWR_DisableWakeUpPin(LP_STANDBY_WKUP_PIN); /* 禁用Standby唤醒引脚 */
222 | LL_PWR_ClearFlag_WU(); /* 清除Standby唤醒标志 */
223 | wkup_exti_deinit();
224 | lptim_init(ms); /* 初始化低功耗定时器 */
225 |
226 | voltage_scale = LL_PWR_GetRegulVoltageScaling(); /* 保存当前电压等级 */
227 | LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE2); /* 设置Vcore电压等级到二级,CPU最高允许8Mhz */
228 | LL_PWR_EnableUltraLowPower(); /* 进入低功耗模式后,关闭VREFINT */
229 | LL_PWR_DisableFastWakeUp(); /* 唤醒后等待VREFINT恢复 */
230 | LL_RCC_SetClkAfterWakeFromStop(LL_RCC_STOP_WAKEUPCLOCK_HSI); /* 设置唤醒后的系统时钟源为HSI16,默认唤醒后为MSI */
231 | LL_PWR_SetRegulModeLP(LL_PWR_REGU_LPMODES_LOW_POWER); /* 设置进入低功耗模式后,稳压器为低功耗模式 */
232 | LL_PWR_SetPowerMode(LL_PWR_MODE_STOP); /* 设置DeepSleep为Stop模式 */
233 | LL_LPM_EnableDeepSleep(); /* 准备进入Stop模式 */
234 | __WFI(); /* 进入Stop模式,等待中断唤醒 */
235 | LL_PWR_SetRegulVoltageScaling(voltage_scale); /* 恢复Vcore电压等级 */
236 |
237 | LL_PWR_DisableUltraLowPower(); /* 恢复电源配置 */
238 | lptim_deinit(); /* 关闭低功耗定时器 */
239 |
240 | __enable_irq(); /* 重新响应所有中断 */
241 | }
242 |
--------------------------------------------------------------------------------
/Src/USER/lowpower.h:
--------------------------------------------------------------------------------
1 | #ifndef _LOWPOWER_H_
2 | #define _LOWPOWER_H_
3 |
4 | #include "main.h"
5 |
6 | /* 可修改 */
7 | #define LP_STANDBY_WKUP_PIN LL_PWR_WAKEUP_PIN1
8 | #define LP_WKUP_EXTI LL_EXTI_LINE_0
9 | #define LP_WKUP_IRQ EXTI0_1_IRQn
10 |
11 | #define LP_LPTIM_NUM LPTIM1
12 | #define LP_LPTIM_EXTI LL_EXTI_LINE_29
13 | #define LP_LPTIM_WKUP_IRQ LPTIM1_IRQn
14 | #define LP_LPTIM_FINAL_CLK 2312.5 /* 此频率下最大延时12秒 */
15 | /* 结束 */
16 |
17 | #define LP_RESET_NONE 0
18 | #define LP_RESET_NORMALRESET 1
19 | #define LP_RESET_POWERON 2
20 | #define LP_RESET_WKUPSTANDBY 3
21 |
22 | void LP_DisableDebug(void);
23 | uint8_t LP_GetResetInfo(void);
24 |
25 | void LP_EnterSleep(uint16_t ms);
26 | void LP_EnterStop(uint16_t ms);
27 | void LP_EnterStandby(void);
28 | void LP_DelayStop(uint16_t ms);
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/Src/USER/lunar.c:
--------------------------------------------------------------------------------
1 | #include "lunar.h"
2 | #include
3 |
4 | /* 2000 ~ 2199 */
5 | const static uint32_t lunar_month_days[] = {
6 | 1997,
7 | 0x0000B26D, 0x0000125C, 0x0000192C, 0x00009A95, 0x00001A94, 0x00001B4A, 0x00004B55, 0x00000AD4, 0x0000F55B,
8 | 0x000004BA, 0x0000125A, 0x0000B92B, 0x0000152A, 0x00001694, 0x000096AA, 0x000015AA, 0x00012AB5, 0x00000974,
9 | 0x000014B6, 0x0000CA57, 0x00000A56, 0x00001526, 0x00008E95, 0x00000D54, 0x000015AA, 0x000049B5, 0x0000096C,
10 | 0x0000D4AE, 0x0000149C, 0x00001A4C, 0x0000BD26, 0x00001AA6, 0x00000B54, 0x00006D6A, 0x000012DA, 0x0001695D,
11 | 0x0000095A, 0x0000149A, 0x0000DA4B, 0x00001A4A, 0x00001AA4, 0x0000BB54, 0x000016B4, 0x00000ADA, 0x0000495B,
12 | 0x00000936, 0x0000F497, 0x00001496, 0x0000154A, 0x0000B6A5, 0x00000DA4, 0x000015B4, 0x00006AB6, 0x0000126E,
13 | 0x0001092F, 0x0000092E, 0x00000C96, 0x0000CD4A, 0x00001D4A, 0x00000D64, 0x0000956C, 0x0000155C, 0x0000125C,
14 | 0x0000792E, 0x0000192C, 0x0000FA95, 0x00001A94, 0x00001B4A, 0x0000AB55, 0x00000AD4, 0x000014DA, 0x00008A5D,
15 | 0x00000A5A, 0x0001152B, 0x0000152A, 0x00001694, 0x0000D6AA, 0x000015AA, 0x00000AB4, 0x000094BA, 0x000014B6,
16 | 0x00000A56, 0x00007527, 0x00000D26, 0x0000EE53, 0x00000D54, 0x000015AA, 0x0000A9B5, 0x0000096C, 0x000014AE,
17 | 0x00008A4E, 0x00001A4C, 0x00011D26, 0x00001AA4, 0x00001B54, 0x0000CD6A, 0x00000ADA, 0x0000095C, 0x0000949D,
18 | 0x0000149A, 0x00001A2A, 0x00005B25, 0x00001AA4, 0x0000FB52, 0x000016B4, 0x00000ABA, 0x0000A95B, 0x00000936,
19 | 0x00001496, 0x00009A4B, 0x0000154A, 0x000136A5, 0x00000DA4, 0x000015AC, 0x0000CAB6, 0x0000126E, 0x0000092E,
20 | 0x00008C97, 0x00000A96, 0x00000D4A, 0x00006DA5, 0x00000D54, 0x0000F56A, 0x0000155A, 0x00000A5C, 0x0000B92E,
21 | 0x0000152C, 0x00001A94, 0x00009D4A, 0x00001B2A, 0x00016B55, 0x00000AD4, 0x000014DA, 0x0000CA5D, 0x00000A5A,
22 | 0x0000151A, 0x0000BA95, 0x00001654, 0x000016AA, 0x00004AD5, 0x00000AB4, 0x0000F4BA, 0x000014B6, 0x00000A56,
23 | 0x0000B517, 0x00000D16, 0x00000E52, 0x000096AA, 0x00000D6A, 0x000165B5, 0x0000096C, 0x000014AE, 0x0000CA2E,
24 | 0x00001A2C, 0x00001D16, 0x0000AD52, 0x00001B52, 0x00000B6A, 0x0000656D, 0x0000055C, 0x0000F45D, 0x0000145A,
25 | 0x00001A2A, 0x0000DA95, 0x000016A4, 0x00001AD2, 0x00008B5A, 0x00000AB6, 0x0001455B, 0x000008B6, 0x00001456,
26 | 0x0000D52B, 0x0000152A, 0x00001694, 0x0000B6AA, 0x000015AA, 0x00000AB6, 0x000064B7, 0x000008AE, 0x0000EC57,
27 | 0x00000A56, 0x00000D2A, 0x0000CD95, 0x00000B54, 0x0000156A, 0x00008A6D, 0x0000095C, 0x000014AE, 0x00004A56,
28 | 0x00001A54, 0x0000DD2A, 0x00001AAA, 0x00000B54, 0x0000B56A, 0x000014DA, 0x0000095C, 0x000074AB, 0x0000149A,
29 | 0x0000FA4B, 0x00001652, 0x000016AA, 0x0000CAD5, 0x000005B4};
30 |
31 | /* 2000 ~ 2199 */
32 | const static uint32_t solar_1_1[] = {
33 | 1997,
34 | 0x000F9C3C, 0x000F9E50, 0x000FA045, 0x000FA238, 0x000FA44C, 0x000FA641, 0x000FA836, 0x000FAA49, 0x000FAC3D,
35 | 0x000FAE52, 0x000FB047, 0x000FB23A, 0x000FB44E, 0x000FB643, 0x000FB837, 0x000FBA4A, 0x000FBC3F, 0x000FBE53,
36 | 0x000FC048, 0x000FC23C, 0x000FC450, 0x000FC645, 0x000FC839, 0x000FCA4C, 0x000FCC41, 0x000FCE36, 0x000FD04A,
37 | 0x000FD23D, 0x000FD451, 0x000FD646, 0x000FD83A, 0x000FDA4D, 0x000FDC43, 0x000FDE37, 0x000FE04B, 0x000FE23F,
38 | 0x000FE453, 0x000FE648, 0x000FE83C, 0x000FEA4F, 0x000FEC44, 0x000FEE38, 0x000FF04C, 0x000FF241, 0x000FF436,
39 | 0x000FF64A, 0x000FF83E, 0x000FFA51, 0x000FFC46, 0x000FFE3A, 0x0010004E, 0x00100242, 0x00100437, 0x0010064B,
40 | 0x00100841, 0x00100A53, 0x00100C48, 0x00100E3C, 0x0010104F, 0x00101244, 0x00101438, 0x0010164C, 0x00101842,
41 | 0x00101A35, 0x00101C49, 0x00101E3D, 0x00102051, 0x00102245, 0x0010243A, 0x0010264E, 0x00102843, 0x00102A37,
42 | 0x00102C4B, 0x00102E3F, 0x00103053, 0x00103247, 0x0010343B, 0x0010364F, 0x00103845, 0x00103A38, 0x00103C4C,
43 | 0x00103E42, 0x00104036, 0x00104249, 0x0010443D, 0x00104651, 0x00104846, 0x00104A3A, 0x00104C4E, 0x00104E43,
44 | 0x00105038, 0x0010524A, 0x0010543E, 0x00105652, 0x00105847, 0x00105A3B, 0x00105C4F, 0x00105E45, 0x00106039,
45 | 0x0010624C, 0x00106441, 0x00106635, 0x00106849, 0x00106A3D, 0x00106C51, 0x00106E47, 0x0010703C, 0x0010724F,
46 | 0x00107444, 0x00107638, 0x0010784C, 0x00107A3F, 0x00107C53, 0x00107E48, 0x0010803D, 0x00108250, 0x00108446,
47 | 0x0010863A, 0x0010884E, 0x00108A42, 0x00108C36, 0x00108E4A, 0x0010903E, 0x00109251, 0x00109447, 0x0010963B,
48 | 0x0010984F, 0x00109A43, 0x00109C37, 0x00109E4B, 0x0010A041, 0x0010A253, 0x0010A448, 0x0010A63D, 0x0010A851,
49 | 0x0010AA45, 0x0010AC39, 0x0010AE4D, 0x0010B042, 0x0010B236, 0x0010B44A, 0x0010B63E, 0x0010B852, 0x0010BA47,
50 | 0x0010BC3B, 0x0010BE4F, 0x0010C044, 0x0010C237, 0x0010C44B, 0x0010C641, 0x0010C854, 0x0010CA48, 0x0010CC3D,
51 | 0x0010CE50, 0x0010D045, 0x0010D239, 0x0010D44C, 0x0010D642, 0x0010D837, 0x0010DA4A, 0x0010DC3E, 0x0010DE52,
52 | 0x0010E047, 0x0010E23A, 0x0010E44E, 0x0010E643, 0x0010E838, 0x0010EA4B, 0x0010EC41, 0x0010EE54, 0x0010F049,
53 | 0x0010F23C, 0x0010F450, 0x0010F645, 0x0010F839, 0x0010FA4C, 0x0010FC42, 0x0010FE37, 0x0011004B, 0x0011023E,
54 | 0x00110452, 0x00110647, 0x0011083B, 0x00110A4E, 0x00110C43, 0x00110E38, 0x0011104C, 0x0011123F, 0x00111435,
55 | 0x00111648, 0x0011183C, 0x00111A4F, 0x00111C45, 0x00111E39, 0x0011204D, 0x00112242, 0x00112436, 0x0011264A,
56 | 0x0011283E, 0x00112A51, 0x00112C46, 0x00112E3B, 0x0011304F};
57 |
58 | static uint32_t GetBitInt(uint32_t data, uint8_t length, uint8_t shift)
59 | {
60 | return (data & (((1 << length) - 1) << shift)) >> shift;
61 | }
62 |
63 | //WARNING: Dates before Oct. 1582 are inaccurate
64 | static uint64_t SolarToInt(uint16_t y, uint8_t m, uint8_t d)
65 | {
66 | m = (m + 9) % 12;
67 | y = y - m / 10;
68 | return 365 * y + y / 4 - y / 100 + y / 400 + (m * 306 + 5) / 10 + (d - 1);
69 | }
70 |
71 | void LUNAR_SolarToLunar(struct Lunar_Date *lunar, uint16_t solar_year, uint8_t solar_month, uint8_t solar_date)
72 | {
73 | uint8_t i, lunarM, m, d, leap, dm;
74 | uint16_t year_index, lunarY, y, offset;
75 | uint32_t solar_data, solar11, days;
76 |
77 | if (solar_month < 1 || solar_month > 12 || solar_date < 1 || solar_date > 31 ||
78 | (solar_year - solar_1_1[0] < 3) || ((solar_year - solar_1_1[0]) > (sizeof(solar_1_1) / sizeof(uint32_t) - 2)))
79 | {
80 | lunar->Year = 0;
81 | lunar->Month = 0;
82 | lunar->Date = 0;
83 | lunar->IsLeap = 0;
84 | return;
85 | }
86 |
87 | year_index = solar_year - solar_1_1[0];
88 | solar_data = (solar_year << 9) | (solar_month << 5) | (solar_date);
89 | if (solar_1_1[year_index] > solar_data)
90 | {
91 | year_index -= 1;
92 | }
93 | solar11 = solar_1_1[year_index];
94 | y = GetBitInt(solar11, 12, 9);
95 | m = GetBitInt(solar11, 4, 5);
96 | d = GetBitInt(solar11, 5, 0);
97 | offset = SolarToInt(solar_year, solar_month, solar_date) - SolarToInt(y, m, d);
98 |
99 | days = lunar_month_days[year_index];
100 | leap = GetBitInt(days, 4, 13);
101 |
102 | lunarY = year_index + solar_1_1[0];
103 | lunarM = 1;
104 | offset += 1;
105 | for (i = 0; i < 13; i++)
106 | {
107 | if (GetBitInt(days, 1, 12 - i) == 1)
108 | {
109 | dm = 30;
110 | }
111 | else
112 | {
113 | dm = 29;
114 | }
115 | if (offset > dm)
116 | {
117 | lunarM += 1;
118 | offset -= dm;
119 | }
120 | else
121 | {
122 | break;
123 | }
124 | }
125 | lunar->IsLeap = 0;
126 | if (leap != 0 && lunarM > leap)
127 | {
128 | if (lunarM == leap + 1)
129 | {
130 | lunar->IsLeap = 1;
131 | }
132 | lunarM -= 1;
133 | }
134 | lunar->Month = lunarM;
135 | lunar->Date = offset;
136 | lunar->Year = lunarY;
137 | }
138 |
139 | uint8_t LUNAR_GetZodiac(const struct Lunar_Date *lunar)
140 | {
141 | return lunar->Year % 12;
142 | }
143 |
144 | uint8_t LUNAR_GetStem(const struct Lunar_Date *lunar)
145 | {
146 | return lunar->Year % 10;
147 | }
148 |
149 | uint8_t LUNAR_GetBranch(const struct Lunar_Date *lunar)
150 | {
151 | return lunar->Year % 12;
152 | }
153 |
--------------------------------------------------------------------------------
/Src/USER/lunar.h:
--------------------------------------------------------------------------------
1 | #ifndef _LUNAR_H_
2 | #define _LUNAR_H_
3 |
4 | #include "main.h"
5 |
6 | struct Lunar_Date
7 | {
8 | uint8_t IsLeap;
9 | uint8_t Date;
10 | uint8_t Month;
11 | uint16_t Year;
12 | };
13 |
14 | const static char Lunar_MonthString[13][7] = {
15 | "未知",
16 | "正月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月",
17 | "冬月", "腊月"};
18 |
19 | const static char Lunar_MonthLeapString[2][4] = {
20 | "",
21 | "润"};
22 |
23 | const static char Lunar_DateString[31][7] = {
24 | "未知",
25 | "初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十",
26 | "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十",
27 | "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十"};
28 |
29 | const static char Lunar_DayString[8][4] = {
30 | " ",
31 | "一", "二", "三", "四", "五", "六", "日"};
32 |
33 | const static char Lunar_ZodiacString[12][4] = {
34 | "猴", "鸡", "狗", "猪", "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊"};
35 |
36 | const static char Lunar_StemStrig[10][4] = {
37 | "庚", "辛", "壬", "癸", "甲", "乙", "丙", "丁", "戊", "已"};
38 |
39 | const static char Lunar_BranchStrig[12][4] = {
40 | "申", "酉", "戌", "亥", "子", "丑", "寅", "卯", "辰", "巳", "午", "未"};
41 |
42 | void LUNAR_SolarToLunar(struct Lunar_Date *lunar, uint16_t solar_year, uint8_t solar_month, uint8_t solar_date);
43 | uint8_t LUNAR_GetZodiac(const struct Lunar_Date *lunar);
44 | uint8_t LUNAR_GetStem(const struct Lunar_Date *lunar);
45 | uint8_t LUNAR_GetBranch(const struct Lunar_Date *lunar);
46 |
47 | #endif
48 |
--------------------------------------------------------------------------------
/Src/USER/serial.c:
--------------------------------------------------------------------------------
1 | #include "serial.h"
2 | #include
3 |
4 | #define WAIT_TIMEOUT(val) \
5 | timeout = SERIAL_TIMEOUT_MS; \
6 | systick_tmp = SysTick->CTRL; \
7 | ((void)systick_tmp); \
8 | while (timeout != 0 && val) \
9 | { \
10 | if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U) \
11 | { \
12 | timeout -= 1; \
13 | } \
14 | } \
15 | if (timeout == 0) \
16 | { \
17 | return; \
18 | }
19 |
20 | /**
21 | * @brief 从串口发送指定大小的数据
22 | * @param tx_data 要发送的数据指针
23 | * @param data_size 要发送的数据大小
24 | */
25 | void SERIAL_SendData(const uint8_t *tx_data, uint32_t data_size)
26 | {
27 | uint32_t timeout;
28 | volatile uint32_t systick_tmp;
29 |
30 | while (data_size != 0)
31 | {
32 | WAIT_TIMEOUT(LL_USART_IsActiveFlag_TXE(SERIAL_NUM) == 0);
33 | LL_USART_ClearFlag_TC(SERIAL_NUM);
34 | LL_USART_TransmitData8(SERIAL_NUM, *tx_data);
35 | tx_data += 1;
36 | data_size -= 1;
37 | }
38 | WAIT_TIMEOUT(LL_USART_IsActiveFlag_TC(SERIAL_NUM) == 0);
39 | }
40 |
41 | /**
42 | * @brief 从串口发送字符串
43 | * @param tx_char 要发送的字符串
44 | */
45 | void SERIAL_SendString(const char *tx_char)
46 | {
47 | uint8_t *char_ptr;
48 | uint8_t char_size;
49 |
50 | char_size = 0;
51 | char_ptr = (uint8_t *)tx_char;
52 | while (*char_ptr != '\0' && char_size < 255)
53 | {
54 | char_ptr += 1;
55 | char_size += 1;
56 | }
57 | SERIAL_SendData((uint8_t *)tx_char, char_size);
58 | }
59 |
60 | /**
61 | * @brief 从串口发送字符串,附加换行符
62 | * @param tx_char 要发送的字符串
63 | */
64 | void SERIAL_SendStringRN(const char *tx_char)
65 | {
66 | SERIAL_SendString(tx_char);
67 | SERIAL_SendData((uint8_t *)"\r\n", 2);
68 | }
69 |
70 | /**
71 | * @brief 从串口发送调试打印信息
72 | * @param file_name 当前程序文件路径字符串指针
73 | * @param func_name 当前函数名称字符串指针
74 | * @param func_line 当前函数所在行
75 | * @param info_str 自定义信息字符串
76 | */
77 | void _SERIAL_DebugPrint(const char *file_name, const char *func_name, uint32_t func_line, const char *info_str)
78 | {
79 | char text[11];
80 | SERIAL_SendString("\r\n**DEBUG PRINT");
81 | SERIAL_SendString("\r\nFILE : ");
82 | SERIAL_SendString(file_name);
83 | SERIAL_SendString("\r\nFUNC : ");
84 | SERIAL_SendString(func_name);
85 | SERIAL_SendString("\r\nLINE : ");
86 | snprintf(text, sizeof(text), "%d", func_line);
87 | SERIAL_SendString(text);
88 | SERIAL_SendString("\r\nINFO : ");
89 | SERIAL_SendString(info_str);
90 | SERIAL_SendString("\r\n\r\n");
91 | }
92 |
--------------------------------------------------------------------------------
/Src/USER/serial.h:
--------------------------------------------------------------------------------
1 | #ifndef _SERIAL_H_
2 | #define _SERIAL_H_
3 |
4 | #include "main.h"
5 |
6 | /* 可修改 */
7 | #define SERIAL_NUM USART1
8 | /* 结束 */
9 |
10 | #define SERIAL_TIMEOUT_MS 1000
11 |
12 | #ifdef ENABLE_DEBUG_PRINT
13 | #define SERIAL_DebugPrint(info_str) _SERIAL_DebugPrint(__FILE__, __FUNCTION__, __LINE__, info_str)
14 | #else
15 | #define SERIAL_DebugPrint(info_str)
16 | #endif
17 |
18 | void SERIAL_SendData(const uint8_t *tx_data, uint32_t data_size);
19 | void SERIAL_SendString(const char *tx_char);
20 | void SERIAL_SendStringRN(const char *tx_char);
21 | void _SERIAL_DebugPrint(const char *file_name, const char *func_name, uint32_t func_line, const char *info_str);
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/Src/USER/sht30.h:
--------------------------------------------------------------------------------
1 | #ifndef _SHT30_H_
2 | #define _SHT30_H_
3 |
4 | #include "main.h"
5 | #include "iic.h"
6 |
7 | /* 可修改 */
8 | #define TH_I2C_ADDR ((0x44 & 0xFE) << 1)
9 | /* 结束 */
10 |
11 | #define TH_ACC_HIGH 0
12 | #define TH_ACC_MID 1
13 | #define TH_ACC_LOW 2
14 |
15 | #define TH_MPS_0_5 0
16 | #define TH_MPS_1 1
17 | #define TH_MPS_2 2
18 | #define TH_MPS_4 3
19 | #define TH_MPS_10 4
20 |
21 | struct TH_Value
22 | {
23 | float RH;
24 | float CEL;
25 | };
26 |
27 | uint8_t TH_WriteCmd(uint16_t command);
28 | uint8_t TH_ReadData(uint8_t *data, uint8_t data_size);
29 | uint8_t TH_ReadCmd(uint16_t command, uint8_t *data, uint8_t data_size);
30 |
31 | uint8_t TH_GetValue_SingleShotWithCS(uint8_t acc, struct TH_Value *value);
32 | uint8_t TH_StartConv_SingleShotWithoutCS(uint8_t acc);
33 | uint8_t TH_GetValue_SingleShotWithoutCS(struct TH_Value *value);
34 |
35 | uint8_t TH_StartConv_Periodic(uint8_t acc, uint8_t mps);
36 | uint8_t TH_StartConv_ART(void);
37 | uint8_t TH_GetValue_Periodic_ART(struct TH_Value *value);
38 |
39 | uint8_t TH_BreakCommand(void);
40 | uint8_t TH_SoftReset(void);
41 | uint8_t TH_ModifyHeater(uint8_t enable);
42 |
43 | uint8_t TH_GetStatus(void);
44 | uint8_t TH_GetAlertPending(void);
45 | uint8_t TH_GetHeaterState(void);
46 | uint8_t TH_GetAlertRHState(void);
47 | uint8_t TH_GetAlertTempState(void);
48 | uint8_t TH_GetResetState(void);
49 | uint8_t TH_GetCmdExecuteState(void);
50 | uint8_t TH_GetDataChecksumState(void);
51 | uint8_t TH_ClearStatus(void);
52 |
53 | void TH_SetTemperatureOffset(float offset);
54 | void TH_SetHumidityOffset(float offset);
55 | float TH_GetTemperatureOffset(void);
56 | float TH_GetHumidityOffset(void);
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/Src/adc.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : ADC.c
4 | * Description : This file provides code for the configuration
5 | * of the ADC instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "adc.h"
22 |
23 | /* USER CODE BEGIN 0 */
24 |
25 | /* USER CODE END 0 */
26 |
27 | /* ADC init function */
28 | void MX_ADC_Init(void)
29 | {
30 | LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0};
31 | LL_ADC_InitTypeDef ADC_InitStruct = {0};
32 |
33 | LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
34 |
35 | /* Peripheral clock enable */
36 | LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
37 |
38 | LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA);
39 | /**ADC GPIO Configuration
40 | PA1 ------> ADC_IN1
41 | */
42 | GPIO_InitStruct.Pin = BATTERY_ADC_IN1_Pin;
43 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
44 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
45 | LL_GPIO_Init(BATTERY_ADC_IN1_GPIO_Port, &GPIO_InitStruct);
46 |
47 | /** Configure Regular Channel
48 | */
49 | LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_1);
50 | /** Configure Regular Channel
51 | */
52 | LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_TEMPSENSOR);
53 | LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_TEMPSENSOR);
54 | /** Configure Regular Channel
55 | */
56 | LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_VREFINT);
57 | LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_VREFINT);
58 | /** Common config
59 | */
60 | ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE;
61 | ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
62 | ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE;
63 | ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE;
64 | ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_PRESERVED;
65 | LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct);
66 | LL_ADC_SetSamplingTimeCommonChannels(ADC1, LL_ADC_SAMPLINGTIME_160CYCLES_5);
67 | LL_ADC_SetOverSamplingScope(ADC1, LL_ADC_OVS_DISABLE);
68 | LL_ADC_REG_SetSequencerScanDirection(ADC1, LL_ADC_REG_SEQ_SCAN_DIR_FORWARD);
69 | LL_ADC_SetCommonFrequencyMode(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_CLOCK_FREQ_MODE_HIGH);
70 | LL_ADC_DisableIT_EOC(ADC1);
71 | LL_ADC_DisableIT_EOS(ADC1);
72 |
73 | /* Enable ADC internal voltage regulator */
74 | LL_ADC_EnableInternalRegulator(ADC1);
75 | /* Delay for ADC internal voltage regulator stabilization. */
76 | /* Compute number of CPU cycles to wait for, from delay in us. */
77 | /* Note: Variable divided by 2 to compensate partially */
78 | /* CPU processing cycles (depends on compilation optimization). */
79 | /* Note: If system core clock frequency is below 200kHz, wait time */
80 | /* is only a few CPU processing cycles. */
81 | uint32_t wait_loop_index;
82 | wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US * (SystemCoreClock / (100000 * 2))) / 10);
83 | while(wait_loop_index != 0)
84 | {
85 | wait_loop_index--;
86 | }
87 | ADC_InitStruct.Clock = LL_ADC_CLOCK_SYNC_PCLK_DIV2;
88 | ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B;
89 | ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;
90 | ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE;
91 | LL_ADC_Init(ADC1, &ADC_InitStruct);
92 |
93 | }
94 |
95 | /* USER CODE BEGIN 1 */
96 |
97 | /* USER CODE END 1 */
98 |
99 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
100 |
--------------------------------------------------------------------------------
/Src/gpio.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : gpio.c
4 | * Description : This file provides code for the configuration
5 | * of all used GPIO pins.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "gpio.h"
22 | /* USER CODE BEGIN 0 */
23 |
24 | /* USER CODE END 0 */
25 |
26 | /*----------------------------------------------------------------------------*/
27 | /* Configure GPIO */
28 | /*----------------------------------------------------------------------------*/
29 | /* USER CODE BEGIN 1 */
30 |
31 | /* USER CODE END 1 */
32 |
33 | /** Configure pins as
34 | * Analog
35 | * Input
36 | * Output
37 | * EVENT_OUT
38 | * EXTI
39 | * Free pins are configured automatically as Analog (this feature is enabled through
40 | * the Code Generation settings)
41 | PB1 ------> SYS_VREF_OUT_PB1
42 | */
43 | void MX_GPIO_Init(void)
44 | {
45 |
46 | LL_EXTI_InitTypeDef EXTI_InitStruct = {0};
47 | LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
48 |
49 | /* GPIO Ports Clock Enable */
50 | LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOC);
51 | LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA);
52 | LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB);
53 |
54 | /**/
55 | LL_GPIO_ResetOutputPin(EPD_DC_GPIO_Port, EPD_DC_Pin);
56 |
57 | /**/
58 | LL_GPIO_ResetOutputPin(EPD_RST_GPIO_Port, EPD_RST_Pin);
59 |
60 | /**/
61 | LL_GPIO_ResetOutputPin(EPD_CS_GPIO_Port, EPD_CS_Pin);
62 |
63 | /**/
64 | LL_GPIO_ResetOutputPin(SHT30_RST_GPIO_Port, SHT30_RST_Pin);
65 |
66 | /**/
67 | LL_GPIO_ResetOutputPin(I2C1_PULLUP_GPIO_Port, I2C1_PULLUP_Pin);
68 |
69 | /**/
70 | LL_GPIO_ResetOutputPin(DC_POWERSAVE_GPIO_Port, DC_POWERSAVE_Pin);
71 |
72 | /**/
73 | LL_GPIO_SetOutputPin(EPD_POWER_GPIO_Port, EPD_POWER_Pin);
74 |
75 | /**/
76 | LL_GPIO_SetOutputPin(LED_GPIO_Port, LED_Pin);
77 |
78 | /**/
79 | LL_GPIO_SetOutputPin(SHT30_POWER_GPIO_Port, SHT30_POWER_Pin);
80 |
81 | /**/
82 | GPIO_InitStruct.Pin = LL_GPIO_PIN_14;
83 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
84 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
85 | LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
86 |
87 | /**/
88 | GPIO_InitStruct.Pin = LL_GPIO_PIN_15;
89 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
90 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
91 | LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
92 |
93 | /**/
94 | GPIO_InitStruct.Pin = EPD_DC_Pin;
95 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
96 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
97 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
98 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
99 | LL_GPIO_Init(EPD_DC_GPIO_Port, &GPIO_InitStruct);
100 |
101 | /**/
102 | GPIO_InitStruct.Pin = EPD_RST_Pin;
103 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
104 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
105 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
106 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
107 | LL_GPIO_Init(EPD_RST_GPIO_Port, &GPIO_InitStruct);
108 |
109 | /**/
110 | GPIO_InitStruct.Pin = EPD_CS_Pin;
111 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
112 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
113 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
114 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
115 | LL_GPIO_Init(EPD_CS_GPIO_Port, &GPIO_InitStruct);
116 |
117 | /**/
118 | GPIO_InitStruct.Pin = LL_GPIO_PIN_1;
119 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
120 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
121 | LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
122 |
123 | /**/
124 | GPIO_InitStruct.Pin = EPD_POWER_Pin;
125 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
126 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
127 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
128 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
129 | LL_GPIO_Init(EPD_POWER_GPIO_Port, &GPIO_InitStruct);
130 |
131 | /**/
132 | GPIO_InitStruct.Pin = LED_Pin;
133 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
134 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
135 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
136 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
137 | LL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);
138 |
139 | /**/
140 | GPIO_InitStruct.Pin = SHT30_POWER_Pin;
141 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
142 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
143 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
144 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
145 | LL_GPIO_Init(SHT30_POWER_GPIO_Port, &GPIO_InitStruct);
146 |
147 | /**/
148 | GPIO_InitStruct.Pin = SHT30_RST_Pin;
149 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
150 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
151 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
152 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
153 | LL_GPIO_Init(SHT30_RST_GPIO_Port, &GPIO_InitStruct);
154 |
155 | /**/
156 | GPIO_InitStruct.Pin = BTN_SET_Pin;
157 | GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
158 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
159 | LL_GPIO_Init(BTN_SET_GPIO_Port, &GPIO_InitStruct);
160 |
161 | /**/
162 | GPIO_InitStruct.Pin = BTN_UP_Pin;
163 | GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
164 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
165 | LL_GPIO_Init(BTN_UP_GPIO_Port, &GPIO_InitStruct);
166 |
167 | /**/
168 | GPIO_InitStruct.Pin = BTN_DOWN_Pin;
169 | GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
170 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
171 | LL_GPIO_Init(BTN_DOWN_GPIO_Port, &GPIO_InitStruct);
172 |
173 | /**/
174 | GPIO_InitStruct.Pin = I2C1_PULLUP_Pin;
175 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
176 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
177 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
178 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
179 | LL_GPIO_Init(I2C1_PULLUP_GPIO_Port, &GPIO_InitStruct);
180 |
181 | /**/
182 | GPIO_InitStruct.Pin = DC_POWERSAVE_Pin;
183 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
184 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
185 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
186 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
187 | LL_GPIO_Init(DC_POWERSAVE_GPIO_Port, &GPIO_InitStruct);
188 |
189 | /**/
190 | LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTB, LL_SYSCFG_EXTI_LINE0);
191 |
192 | /**/
193 | LL_GPIO_SetPinPull(EPD_BUSY_EXTI0_GPIO_Port, EPD_BUSY_EXTI0_Pin, LL_GPIO_PULL_DOWN);
194 |
195 | /**/
196 | LL_GPIO_SetPinMode(EPD_BUSY_EXTI0_GPIO_Port, EPD_BUSY_EXTI0_Pin, LL_GPIO_MODE_INPUT);
197 |
198 | /**/
199 | EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_0;
200 | EXTI_InitStruct.LineCommand = ENABLE;
201 | EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
202 | EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_FALLING;
203 | LL_EXTI_Init(&EXTI_InitStruct);
204 |
205 | }
206 |
207 | /* USER CODE BEGIN 2 */
208 |
209 | /* USER CODE END 2 */
210 |
211 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
212 |
--------------------------------------------------------------------------------
/Src/i2c.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : I2C.c
4 | * Description : This file provides code for the configuration
5 | * of the I2C instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "i2c.h"
22 |
23 | /* USER CODE BEGIN 0 */
24 |
25 | /* USER CODE END 0 */
26 |
27 | /* I2C1 init function */
28 | void MX_I2C1_Init(void)
29 | {
30 | LL_I2C_InitTypeDef I2C_InitStruct = {0};
31 |
32 | LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
33 |
34 | LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB);
35 | /**I2C1 GPIO Configuration
36 | PB6 ------> I2C1_SCL
37 | PB7 ------> I2C1_SDA
38 | */
39 | GPIO_InitStruct.Pin = LL_GPIO_PIN_6;
40 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
41 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
42 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
43 | GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
44 | GPIO_InitStruct.Alternate = LL_GPIO_AF_1;
45 | LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
46 |
47 | GPIO_InitStruct.Pin = LL_GPIO_PIN_7;
48 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
49 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
50 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
51 | GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
52 | GPIO_InitStruct.Alternate = LL_GPIO_AF_1;
53 | LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
54 |
55 | /* Peripheral clock enable */
56 | LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C1);
57 |
58 | /** I2C Initialization
59 | */
60 | LL_I2C_EnableAutoEndMode(I2C1);
61 | LL_I2C_DisableOwnAddress2(I2C1);
62 | LL_I2C_DisableGeneralCall(I2C1);
63 | LL_I2C_EnableClockStretching(I2C1);
64 | I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C;
65 | I2C_InitStruct.Timing = 0x0010020B;
66 | I2C_InitStruct.AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE;
67 | I2C_InitStruct.DigitalFilter = 0;
68 | I2C_InitStruct.OwnAddress1 = 0;
69 | I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK;
70 | I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT;
71 | LL_I2C_Init(I2C1, &I2C_InitStruct);
72 | LL_I2C_SetOwnAddress2(I2C1, 0, LL_I2C_OWNADDRESS2_NOMASK);
73 |
74 | }
75 |
76 | /* USER CODE BEGIN 1 */
77 |
78 | /* USER CODE END 1 */
79 |
80 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
81 |
--------------------------------------------------------------------------------
/Src/lptim.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : LPTIM.c
4 | * Description : This file provides code for the configuration
5 | * of the LPTIM instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "lptim.h"
22 |
23 | /* USER CODE BEGIN 0 */
24 |
25 | /* USER CODE END 0 */
26 |
27 | /* LPTIM1 init function */
28 | void MX_LPTIM1_Init(void)
29 | {
30 |
31 | /* Peripheral clock enable */
32 | LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_LPTIM1);
33 |
34 | LL_LPTIM_SetClockSource(LPTIM1, LL_LPTIM_CLK_SOURCE_INTERNAL);
35 | LL_LPTIM_SetPrescaler(LPTIM1, LL_LPTIM_PRESCALER_DIV16);
36 | LL_LPTIM_SetPolarity(LPTIM1, LL_LPTIM_OUTPUT_POLARITY_REGULAR);
37 | LL_LPTIM_SetUpdateMode(LPTIM1, LL_LPTIM_UPDATE_MODE_IMMEDIATE);
38 | LL_LPTIM_SetCounterMode(LPTIM1, LL_LPTIM_COUNTER_MODE_INTERNAL);
39 | LL_LPTIM_TrigSw(LPTIM1);
40 |
41 | }
42 |
43 | /* USER CODE BEGIN 1 */
44 |
45 | /* USER CODE END 1 */
46 |
47 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
48 |
--------------------------------------------------------------------------------
/Src/main.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : main.c
5 | * @brief : Main program body
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "main.h"
22 | #include "adc.h"
23 | #include "i2c.h"
24 | #include "lptim.h"
25 | #include "spi.h"
26 | #include "tim.h"
27 | #include "usart.h"
28 | #include "gpio.h"
29 |
30 | /* Private includes ----------------------------------------------------------*/
31 | /* USER CODE BEGIN Includes */
32 | #include "func.h"
33 | /* USER CODE END Includes */
34 |
35 | /* Private typedef -----------------------------------------------------------*/
36 | /* USER CODE BEGIN PTD */
37 |
38 | /* USER CODE END PTD */
39 |
40 | /* Private define ------------------------------------------------------------*/
41 | /* USER CODE BEGIN PD */
42 | /* USER CODE END PD */
43 |
44 | /* Private macro -------------------------------------------------------------*/
45 | /* USER CODE BEGIN PM */
46 |
47 | /* USER CODE END PM */
48 |
49 | /* Private variables ---------------------------------------------------------*/
50 |
51 | /* USER CODE BEGIN PV */
52 |
53 | /* USER CODE END PV */
54 |
55 | /* Private function prototypes -----------------------------------------------*/
56 | void SystemClock_Config(void);
57 | /* USER CODE BEGIN PFP */
58 |
59 | /* USER CODE END PFP */
60 |
61 | /* Private user code ---------------------------------------------------------*/
62 | /* USER CODE BEGIN 0 */
63 |
64 | /* USER CODE END 0 */
65 |
66 | /**
67 | * @brief The application entry point.
68 | * @retval int
69 | */
70 | int main(void)
71 | {
72 | /* USER CODE BEGIN 1 */
73 |
74 | /* USER CODE END 1 */
75 |
76 | /* MCU Configuration--------------------------------------------------------*/
77 |
78 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
79 |
80 | LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
81 | LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
82 |
83 | /* System interrupt init*/
84 |
85 | /** Select which pad is connected to VREFINT_ADC
86 | */
87 | LL_SYSCFG_VREFINT_SetConnection(LL_SYSCFG_VREFINT_CONNECT_IO2);
88 |
89 | /* USER CODE BEGIN Init */
90 |
91 | /* USER CODE END Init */
92 |
93 | /* Configure the system clock */
94 | SystemClock_Config();
95 |
96 | /* USER CODE BEGIN SysInit */
97 |
98 | /* USER CODE END SysInit */
99 |
100 | /* Initialize all configured peripherals */
101 | MX_GPIO_Init();
102 | MX_ADC_Init();
103 | MX_I2C1_Init();
104 | MX_SPI1_Init();
105 | MX_USART1_UART_Init();
106 | MX_TIM2_Init();
107 | MX_LPTIM1_Init();
108 | /* USER CODE BEGIN 2 */
109 | Init();
110 | /* USER CODE END 2 */
111 |
112 | /* Infinite loop */
113 | /* USER CODE BEGIN WHILE */
114 | while (1)
115 | {
116 | for (;;)
117 | {
118 | Loop();
119 | }
120 | /* USER CODE END WHILE */
121 |
122 | /* USER CODE BEGIN 3 */
123 | }
124 | /* USER CODE END 3 */
125 | }
126 |
127 | /**
128 | * @brief System Clock Configuration
129 | * @retval None
130 | */
131 | void SystemClock_Config(void)
132 | {
133 | LL_FLASH_SetLatency(LL_FLASH_LATENCY_0);
134 | while(LL_FLASH_GetLatency()!= LL_FLASH_LATENCY_0)
135 | {
136 | }
137 | LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);
138 | LL_RCC_HSI_Enable();
139 |
140 | /* Wait till HSI is ready */
141 | while(LL_RCC_HSI_IsReady() != 1)
142 | {
143 |
144 | }
145 | LL_RCC_HSI_SetCalibTrimming(16);
146 | LL_RCC_LSI_Enable();
147 |
148 | /* Wait till LSI is ready */
149 | while(LL_RCC_LSI_IsReady() != 1)
150 | {
151 |
152 | }
153 | LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2);
154 | LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
155 | LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
156 | LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
157 |
158 | /* Wait till System clock is ready */
159 | while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI)
160 | {
161 |
162 | }
163 |
164 | LL_Init1msTick(8000000);
165 |
166 | LL_SetSystemCoreClock(8000000);
167 | LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK2);
168 | LL_RCC_SetI2CClockSource(LL_RCC_I2C1_CLKSOURCE_PCLK1);
169 | LL_RCC_SetLPTIMClockSource(LL_RCC_LPTIM1_CLKSOURCE_LSI);
170 | }
171 |
172 | /* USER CODE BEGIN 4 */
173 |
174 | /* USER CODE END 4 */
175 |
176 | /**
177 | * @brief This function is executed in case of error occurrence.
178 | * @retval None
179 | */
180 | void Error_Handler(void)
181 | {
182 | /* USER CODE BEGIN Error_Handler_Debug */
183 | /* User can add his own implementation to report the HAL error return state */
184 |
185 | /* USER CODE END Error_Handler_Debug */
186 | }
187 |
188 | #ifdef USE_FULL_ASSERT
189 | /**
190 | * @brief Reports the name of the source file and the source line number
191 | * where the assert_param error has occurred.
192 | * @param file: pointer to the source file name
193 | * @param line: assert_param error line source number
194 | * @retval None
195 | */
196 | void assert_failed(uint8_t *file, uint32_t line)
197 | {
198 | /* USER CODE BEGIN 6 */
199 | /* User can add his own implementation to report the file name and line number,
200 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
201 | /* USER CODE END 6 */
202 | }
203 | #endif /* USE_FULL_ASSERT */
204 |
205 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
206 |
--------------------------------------------------------------------------------
/Src/spi.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : SPI.c
4 | * Description : This file provides code for the configuration
5 | * of the SPI instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "spi.h"
22 |
23 | /* USER CODE BEGIN 0 */
24 |
25 | /* USER CODE END 0 */
26 |
27 | /* SPI1 init function */
28 | void MX_SPI1_Init(void)
29 | {
30 | LL_SPI_InitTypeDef SPI_InitStruct = {0};
31 |
32 | LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
33 |
34 | /* Peripheral clock enable */
35 | LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SPI1);
36 |
37 | LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA);
38 | /**SPI1 GPIO Configuration
39 | PA5 ------> SPI1_SCK
40 | PA7 ------> SPI1_MOSI
41 | */
42 | GPIO_InitStruct.Pin = EPD_SCK_Pin;
43 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
44 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
45 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
46 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
47 | GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
48 | LL_GPIO_Init(EPD_SCK_GPIO_Port, &GPIO_InitStruct);
49 |
50 | GPIO_InitStruct.Pin = EPD_MOSI_Pin;
51 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
52 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
53 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
54 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
55 | GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
56 | LL_GPIO_Init(EPD_MOSI_GPIO_Port, &GPIO_InitStruct);
57 |
58 | SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
59 | SPI_InitStruct.Mode = LL_SPI_MODE_MASTER;
60 | SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
61 | SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_HIGH;
62 | SPI_InitStruct.ClockPhase = LL_SPI_PHASE_2EDGE;
63 | SPI_InitStruct.NSS = LL_SPI_NSS_SOFT;
64 | SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV2;
65 | SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST;
66 | SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
67 | SPI_InitStruct.CRCPoly = 7;
68 | LL_SPI_Init(SPI1, &SPI_InitStruct);
69 | LL_SPI_SetStandard(SPI1, LL_SPI_PROTOCOL_MOTOROLA);
70 |
71 | }
72 |
73 | /* USER CODE BEGIN 1 */
74 |
75 | /* USER CODE END 1 */
76 |
77 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
78 |
--------------------------------------------------------------------------------
/Src/stm32l0xx_it.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32l0xx_it.c
5 | * @brief Interrupt Service Routines.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "main.h"
23 | #include "stm32l0xx_it.h"
24 | /* Private includes ----------------------------------------------------------*/
25 | /* USER CODE BEGIN Includes */
26 | /* USER CODE END Includes */
27 |
28 | /* Private typedef -----------------------------------------------------------*/
29 | /* USER CODE BEGIN TD */
30 |
31 | /* USER CODE END TD */
32 |
33 | /* Private define ------------------------------------------------------------*/
34 | /* USER CODE BEGIN PD */
35 |
36 | /* USER CODE END PD */
37 |
38 | /* Private macro -------------------------------------------------------------*/
39 | /* USER CODE BEGIN PM */
40 |
41 | /* USER CODE END PM */
42 |
43 | /* Private variables ---------------------------------------------------------*/
44 | /* USER CODE BEGIN PV */
45 |
46 | /* USER CODE END PV */
47 |
48 | /* Private function prototypes -----------------------------------------------*/
49 | /* USER CODE BEGIN PFP */
50 |
51 | /* USER CODE END PFP */
52 |
53 | /* Private user code ---------------------------------------------------------*/
54 | /* USER CODE BEGIN 0 */
55 |
56 | /* USER CODE END 0 */
57 |
58 | /* External variables --------------------------------------------------------*/
59 |
60 | /* USER CODE BEGIN EV */
61 |
62 | /* USER CODE END EV */
63 |
64 | /******************************************************************************/
65 | /* Cortex-M0+ Processor Interruption and Exception Handlers */
66 | /******************************************************************************/
67 | /**
68 | * @brief This function handles Non maskable interrupt.
69 | */
70 | void NMI_Handler(void)
71 | {
72 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
73 |
74 | /* USER CODE END NonMaskableInt_IRQn 0 */
75 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
76 |
77 | /* USER CODE END NonMaskableInt_IRQn 1 */
78 | }
79 |
80 | /**
81 | * @brief This function handles Hard fault interrupt.
82 | */
83 | void HardFault_Handler(void)
84 | {
85 | /* USER CODE BEGIN HardFault_IRQn 0 */
86 |
87 | /* USER CODE END HardFault_IRQn 0 */
88 | while (1)
89 | {
90 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */
91 | NVIC_SystemReset();
92 | /* USER CODE END W1_HardFault_IRQn 0 */
93 | }
94 | }
95 |
96 | /**
97 | * @brief This function handles System service call via SWI instruction.
98 | */
99 | void SVC_Handler(void)
100 | {
101 | /* USER CODE BEGIN SVC_IRQn 0 */
102 |
103 | /* USER CODE END SVC_IRQn 0 */
104 | /* USER CODE BEGIN SVC_IRQn 1 */
105 |
106 | /* USER CODE END SVC_IRQn 1 */
107 | }
108 |
109 | /**
110 | * @brief This function handles Pendable request for system service.
111 | */
112 | void PendSV_Handler(void)
113 | {
114 | /* USER CODE BEGIN PendSV_IRQn 0 */
115 |
116 | /* USER CODE END PendSV_IRQn 0 */
117 | /* USER CODE BEGIN PendSV_IRQn 1 */
118 |
119 | /* USER CODE END PendSV_IRQn 1 */
120 | }
121 |
122 | /**
123 | * @brief This function handles System tick timer.
124 | */
125 | void SysTick_Handler(void)
126 | {
127 | /* USER CODE BEGIN SysTick_IRQn 0 */
128 |
129 | /* USER CODE END SysTick_IRQn 0 */
130 |
131 | /* USER CODE BEGIN SysTick_IRQn 1 */
132 |
133 | /* USER CODE END SysTick_IRQn 1 */
134 | }
135 |
136 | /******************************************************************************/
137 | /* STM32L0xx Peripheral Interrupt Handlers */
138 | /* Add here the Interrupt Handlers for the used peripherals. */
139 | /* For the available peripheral interrupt handler names, */
140 | /* please refer to the startup file (startup_stm32l0xx.s). */
141 | /******************************************************************************/
142 |
143 | /* USER CODE BEGIN 1 */
144 |
145 | /* USER CODE END 1 */
146 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
147 |
--------------------------------------------------------------------------------
/Src/system_stm32l0xx.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32l0xx.c
4 | * @author MCD Application Team
5 | * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Source File.
6 | *
7 | * This file provides two functions and one global variable to be called from
8 | * user application:
9 | * - SystemInit(): This function is called at startup just after reset and
10 | * before branch to main program. This call is made inside
11 | * the "startup_stm32l0xx.s" file.
12 | *
13 | * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
14 | * by the user application to setup the SysTick
15 | * timer or configure other parameters.
16 | *
17 | * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
18 | * be called whenever the core clock is changed
19 | * during program execution.
20 | *
21 | *
22 | ******************************************************************************
23 | * @attention
24 | *
25 | * © Copyright(c) 2016 STMicroelectronics.
26 | * All rights reserved.
27 | *
28 | * This software component is licensed by ST under BSD 3-Clause license,
29 | * the "License"; You may not use this file except in compliance with the
30 | * License. You may obtain a copy of the License at:
31 | * opensource.org/licenses/BSD-3-Clause
32 | *
33 | ******************************************************************************
34 | */
35 |
36 | /** @addtogroup CMSIS
37 | * @{
38 | */
39 |
40 | /** @addtogroup stm32l0xx_system
41 | * @{
42 | */
43 |
44 | /** @addtogroup STM32L0xx_System_Private_Includes
45 | * @{
46 | */
47 |
48 | #include "stm32l0xx.h"
49 |
50 | #if !defined (HSE_VALUE)
51 | #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
52 | #endif /* HSE_VALUE */
53 |
54 | #if !defined (MSI_VALUE)
55 | #define MSI_VALUE ((uint32_t)2097152U) /*!< Value of the Internal oscillator in Hz*/
56 | #endif /* MSI_VALUE */
57 |
58 | #if !defined (HSI_VALUE)
59 | #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
60 | #endif /* HSI_VALUE */
61 |
62 |
63 | /**
64 | * @}
65 | */
66 |
67 | /** @addtogroup STM32L0xx_System_Private_TypesDefinitions
68 | * @{
69 | */
70 |
71 | /**
72 | * @}
73 | */
74 |
75 | /** @addtogroup STM32L0xx_System_Private_Defines
76 | * @{
77 | */
78 | /************************* Miscellaneous Configuration ************************/
79 |
80 | /*!< Uncomment the following line if you need to relocate your vector Table in
81 | Internal SRAM. */
82 | /* #define VECT_TAB_SRAM */
83 | #define VECT_TAB_OFFSET 0x00U /*!< Vector Table base offset field.
84 | This value must be a multiple of 0x100. */
85 | /******************************************************************************/
86 | /**
87 | * @}
88 | */
89 |
90 | /** @addtogroup STM32L0xx_System_Private_Macros
91 | * @{
92 | */
93 |
94 | /**
95 | * @}
96 | */
97 |
98 | /** @addtogroup STM32L0xx_System_Private_Variables
99 | * @{
100 | */
101 | /* This variable is updated in three ways:
102 | 1) by calling CMSIS function SystemCoreClockUpdate()
103 | 2) by calling HAL API function HAL_RCC_GetHCLKFreq()
104 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
105 | Note: If you use this function to configure the system clock; then there
106 | is no need to call the 2 first functions listed above, since SystemCoreClock
107 | variable is updated automatically.
108 | */
109 | uint32_t SystemCoreClock = 2097152U; /* 32.768 kHz * 2^6 */
110 | const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U};
111 | const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U};
112 | const uint8_t PLLMulTable[9] = {3U, 4U, 6U, 8U, 12U, 16U, 24U, 32U, 48U};
113 |
114 | /**
115 | * @}
116 | */
117 |
118 | /** @addtogroup STM32L0xx_System_Private_FunctionPrototypes
119 | * @{
120 | */
121 |
122 | /**
123 | * @}
124 | */
125 |
126 | /** @addtogroup STM32L0xx_System_Private_Functions
127 | * @{
128 | */
129 |
130 | /**
131 | * @brief Setup the microcontroller system.
132 | * @param None
133 | * @retval None
134 | */
135 | void SystemInit (void)
136 | {
137 | /*!< Set MSION bit */
138 | RCC->CR |= (uint32_t)0x00000100U;
139 |
140 | /*!< Reset SW[1:0], HPRE[3:0], PPRE1[2:0], PPRE2[2:0], MCOSEL[2:0] and MCOPRE[2:0] bits */
141 | RCC->CFGR &= (uint32_t) 0x88FF400CU;
142 |
143 | /*!< Reset HSION, HSIDIVEN, HSEON, CSSON and PLLON bits */
144 | RCC->CR &= (uint32_t)0xFEF6FFF6U;
145 |
146 | /*!< Reset HSI48ON bit */
147 | RCC->CRRCR &= (uint32_t)0xFFFFFFFEU;
148 |
149 | /*!< Reset HSEBYP bit */
150 | RCC->CR &= (uint32_t)0xFFFBFFFFU;
151 |
152 | /*!< Reset PLLSRC, PLLMUL[3:0] and PLLDIV[1:0] bits */
153 | RCC->CFGR &= (uint32_t)0xFF02FFFFU;
154 |
155 | /*!< Disable all interrupts */
156 | RCC->CIER = 0x00000000U;
157 |
158 | /* Configure the Vector Table location add offset address ------------------*/
159 | #ifdef VECT_TAB_SRAM
160 | SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
161 | #else
162 | SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
163 | #endif
164 | }
165 |
166 | /**
167 | * @brief Update SystemCoreClock according to Clock Register Values
168 | * The SystemCoreClock variable contains the core clock (HCLK), it can
169 | * be used by the user application to setup the SysTick timer or configure
170 | * other parameters.
171 | *
172 | * @note Each time the core clock (HCLK) changes, this function must be called
173 | * to update SystemCoreClock variable value. Otherwise, any configuration
174 | * based on this variable will be incorrect.
175 | *
176 | * @note - The system frequency computed by this function is not the real
177 | * frequency in the chip. It is calculated based on the predefined
178 | * constant and the selected clock source:
179 | *
180 | * - If SYSCLK source is MSI, SystemCoreClock will contain the MSI
181 | * value as defined by the MSI range.
182 | *
183 | * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
184 | *
185 | * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
186 | *
187 | * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
188 | * or HSI_VALUE(*) multiplied/divided by the PLL factors.
189 | *
190 | * (*) HSI_VALUE is a constant defined in stm32l0xx_hal.h file (default value
191 | * 16 MHz) but the real value may vary depending on the variations
192 | * in voltage and temperature.
193 | *
194 | * (**) HSE_VALUE is a constant defined in stm32l0xx_hal.h file (default value
195 | * 8 MHz), user has to ensure that HSE_VALUE is same as the real
196 | * frequency of the crystal used. Otherwise, this function may
197 | * have wrong result.
198 | *
199 | * - The result of this function could be not correct when using fractional
200 | * value for HSE crystal.
201 | * @param None
202 | * @retval None
203 | */
204 | void SystemCoreClockUpdate (void)
205 | {
206 | uint32_t tmp = 0U, pllmul = 0U, plldiv = 0U, pllsource = 0U, msirange = 0U;
207 |
208 | /* Get SYSCLK source -------------------------------------------------------*/
209 | tmp = RCC->CFGR & RCC_CFGR_SWS;
210 |
211 | switch (tmp)
212 | {
213 | case 0x00U: /* MSI used as system clock */
214 | msirange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE) >> RCC_ICSCR_MSIRANGE_Pos;
215 | SystemCoreClock = (32768U * (1U << (msirange + 1U)));
216 | break;
217 | case 0x04U: /* HSI used as system clock */
218 | if ((RCC->CR & RCC_CR_HSIDIVF) != 0U)
219 | {
220 | SystemCoreClock = HSI_VALUE / 4U;
221 | }
222 | else
223 | {
224 | SystemCoreClock = HSI_VALUE;
225 | }
226 | break;
227 | case 0x08U: /* HSE used as system clock */
228 | SystemCoreClock = HSE_VALUE;
229 | break;
230 | default: /* PLL used as system clock */
231 | /* Get PLL clock source and multiplication factor ----------------------*/
232 | pllmul = RCC->CFGR & RCC_CFGR_PLLMUL;
233 | plldiv = RCC->CFGR & RCC_CFGR_PLLDIV;
234 | pllmul = PLLMulTable[(pllmul >> RCC_CFGR_PLLMUL_Pos)];
235 | plldiv = (plldiv >> RCC_CFGR_PLLDIV_Pos) + 1U;
236 |
237 | pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
238 |
239 | if (pllsource == 0x00U)
240 | {
241 | /* HSI oscillator clock selected as PLL clock entry */
242 | if ((RCC->CR & RCC_CR_HSIDIVF) != 0U)
243 | {
244 | SystemCoreClock = (((HSI_VALUE / 4U) * pllmul) / plldiv);
245 | }
246 | else
247 | {
248 | SystemCoreClock = (((HSI_VALUE) * pllmul) / plldiv);
249 | }
250 | }
251 | else
252 | {
253 | /* HSE selected as PLL clock entry */
254 | SystemCoreClock = (((HSE_VALUE) * pllmul) / plldiv);
255 | }
256 | break;
257 | }
258 | /* Compute HCLK clock frequency --------------------------------------------*/
259 | /* Get HCLK prescaler */
260 | tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> RCC_CFGR_HPRE_Pos)];
261 | /* HCLK clock frequency */
262 | SystemCoreClock >>= tmp;
263 | }
264 |
265 |
266 |
267 | /**
268 | * @}
269 | */
270 |
271 | /**
272 | * @}
273 | */
274 |
275 | /**
276 | * @}
277 | */
278 |
279 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
280 |
--------------------------------------------------------------------------------
/Src/tim.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : TIM.c
4 | * Description : This file provides code for the configuration
5 | * of the TIM instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "tim.h"
22 |
23 | /* USER CODE BEGIN 0 */
24 |
25 | /* USER CODE END 0 */
26 |
27 | /* TIM2 init function */
28 | void MX_TIM2_Init(void)
29 | {
30 | LL_TIM_InitTypeDef TIM_InitStruct = {0};
31 | LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0};
32 |
33 | LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
34 | /* Peripheral clock enable */
35 | LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
36 |
37 | TIM_InitStruct.Prescaler = 7;
38 | TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
39 | TIM_InitStruct.Autoreload = 249;
40 | TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
41 | LL_TIM_Init(TIM2, &TIM_InitStruct);
42 | LL_TIM_DisableARRPreload(TIM2);
43 | LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL);
44 | LL_TIM_OC_EnablePreload(TIM2, LL_TIM_CHANNEL_CH3);
45 | TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM1;
46 | TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE;
47 | TIM_OC_InitStruct.CompareValue = 124;
48 | TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_LOW;
49 | LL_TIM_OC_Init(TIM2, LL_TIM_CHANNEL_CH3, &TIM_OC_InitStruct);
50 | LL_TIM_OC_DisableFast(TIM2, LL_TIM_CHANNEL_CH3);
51 | LL_TIM_SetTriggerOutput(TIM2, LL_TIM_TRGO_RESET);
52 | LL_TIM_DisableMasterSlaveMode(TIM2);
53 | LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA);
54 | /**TIM2 GPIO Configuration
55 | PA2 ------> TIM2_CH3
56 | */
57 | GPIO_InitStruct.Pin = BUZZER_TIM2_CH3_Pin;
58 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
59 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
60 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
61 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
62 | GPIO_InitStruct.Alternate = LL_GPIO_AF_2;
63 | LL_GPIO_Init(BUZZER_TIM2_CH3_GPIO_Port, &GPIO_InitStruct);
64 |
65 | }
66 |
67 | /* USER CODE BEGIN 1 */
68 |
69 | /* USER CODE END 1 */
70 |
71 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
72 |
--------------------------------------------------------------------------------
/Src/usart.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : USART.c
4 | * Description : This file provides code for the configuration
5 | * of the USART instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2020 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "usart.h"
22 |
23 | /* USER CODE BEGIN 0 */
24 |
25 | /* USER CODE END 0 */
26 |
27 | /* USART1 init function */
28 |
29 | void MX_USART1_UART_Init(void)
30 | {
31 | LL_USART_InitTypeDef USART_InitStruct = {0};
32 |
33 | LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
34 |
35 | /* Peripheral clock enable */
36 | LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
37 |
38 | LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA);
39 | /**USART1 GPIO Configuration
40 | PA9 ------> USART1_TX
41 | PA10 ------> USART1_RX
42 | */
43 | GPIO_InitStruct.Pin = LL_GPIO_PIN_9;
44 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
45 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
46 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
47 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
48 | GPIO_InitStruct.Alternate = LL_GPIO_AF_4;
49 | LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
50 |
51 | GPIO_InitStruct.Pin = LL_GPIO_PIN_10;
52 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
53 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
54 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
55 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
56 | GPIO_InitStruct.Alternate = LL_GPIO_AF_4;
57 | LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
58 |
59 | USART_InitStruct.BaudRate = 115200;
60 | USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
61 | USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
62 | USART_InitStruct.Parity = LL_USART_PARITY_NONE;
63 | USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;
64 | USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
65 | USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16;
66 | LL_USART_Init(USART1, &USART_InitStruct);
67 | LL_USART_ConfigAsyncMode(USART1);
68 | LL_USART_Enable(USART1);
69 |
70 | }
71 |
72 | /* USER CODE BEGIN 1 */
73 |
74 | /* USER CODE END 1 */
75 |
76 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
77 |
--------------------------------------------------------------------------------
/带链接的BOM表.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/带链接的BOM表.xls
--------------------------------------------------------------------------------
/资源/PCB/AltiumDesigner/2.9inch_EPD_Module.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/PCB/AltiumDesigner/2.9inch_EPD_Module.zip
--------------------------------------------------------------------------------
/资源/PCB/AltiumDesigner/MultiBoard_2.9EPD+L051.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/PCB/AltiumDesigner/MultiBoard_2.9EPD+L051.zip
--------------------------------------------------------------------------------
/资源/PCB/AltiumDesigner/STM32L051K8U6_LOWPOWER_CLOCK.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/PCB/AltiumDesigner/STM32L051K8U6_LOWPOWER_CLOCK.zip
--------------------------------------------------------------------------------
/资源/位图/12x24/$.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/12x24/$.BMP
--------------------------------------------------------------------------------
/资源/位图/12x24/&.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/12x24/&.BMP
--------------------------------------------------------------------------------
/资源/位图/12x24/@.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/12x24/@.BMP
--------------------------------------------------------------------------------
/资源/位图/16x16/一.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/16x16/一.BMP
--------------------------------------------------------------------------------
/资源/位图/16x16/三.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/16x16/三.BMP
--------------------------------------------------------------------------------
/资源/位图/16x16/二.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/16x16/二.BMP
--------------------------------------------------------------------------------
/资源/位图/16x16/十.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/16x16/十.BMP
--------------------------------------------------------------------------------
/资源/位图/16x16/度.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/16x16/度.BMP
--------------------------------------------------------------------------------
/资源/位图/24x24/一.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/24x24/一.BMP
--------------------------------------------------------------------------------
/资源/位图/24x24/三.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/24x24/三.BMP
--------------------------------------------------------------------------------
/资源/位图/24x24/上箭头.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/24x24/上箭头.BMP
--------------------------------------------------------------------------------
/资源/位图/24x24/二.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/24x24/二.BMP
--------------------------------------------------------------------------------
/资源/位图/24x24/十.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/24x24/十.BMP
--------------------------------------------------------------------------------
/资源/位图/24x24/右箭头.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/24x24/右箭头.BMP
--------------------------------------------------------------------------------
/资源/位图/24x24/左箭头.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/24x24/左箭头.bmp
--------------------------------------------------------------------------------
/资源/位图/24x24/温度.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/24x24/温度.bmp
--------------------------------------------------------------------------------
/资源/位图/24x24/百分.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/24x24/百分.bmp
--------------------------------------------------------------------------------
/资源/位图/上箭头_12x8.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/上箭头_12x8.BMP
--------------------------------------------------------------------------------
/资源/位图/上箭头_8x8.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/上箭头_8x8.BMP
--------------------------------------------------------------------------------
/资源/位图/欢迎_296x96.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/欢迎_296x96.bmp
--------------------------------------------------------------------------------
/资源/位图/欢迎界面.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/欢迎界面.xcf
--------------------------------------------------------------------------------
/资源/位图/电池电量低_296x128.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/电池电量低_296x128.bmp
--------------------------------------------------------------------------------
/资源/位图/电池警告_37x24.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/电池警告_37x24.bmp
--------------------------------------------------------------------------------
/资源/位图/系统信息_89x128.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/位图/系统信息_89x128.bmp
--------------------------------------------------------------------------------
/资源/农历数据生成/项目地址.txt:
--------------------------------------------------------------------------------
1 | https://github.com/isee15/Lunar-Solar-Calendar-Converter
--------------------------------------------------------------------------------
/资源/字体/2015Jun24-Font-Truetype.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/字体/2015Jun24-Font-Truetype.zip
--------------------------------------------------------------------------------
/资源/字体/digital_dismay.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/字体/digital_dismay.zip
--------------------------------------------------------------------------------
/资源/字模取模/PCtoLCD2002.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/字模取模/PCtoLCD2002.zip
--------------------------------------------------------------------------------
/资源/字模取模/字模转换.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/字模取模/字模转换.zip
--------------------------------------------------------------------------------
/资源/数据表/DIP_AAA_1023.PDF:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/DIP_AAA_1023.PDF
--------------------------------------------------------------------------------
/资源/数据表/DS3231.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/DS3231.pdf
--------------------------------------------------------------------------------
/资源/数据表/HINK-E029A01-0629.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/HINK-E029A01-0629.pdf
--------------------------------------------------------------------------------
/资源/数据表/Sensirion_Humidity_Sensors_SHT3x_Datasheet_digital.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/Sensirion_Humidity_Sensors_SHT3x_Datasheet_digital.pdf
--------------------------------------------------------------------------------
/资源/数据表/Si2305DS.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/Si2305DS.pdf
--------------------------------------------------------------------------------
/资源/数据表/irlml6344pbf.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/irlml6344pbf.pdf
--------------------------------------------------------------------------------
/资源/数据表/sn74lvc1g00.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/sn74lvc1g00.pdf
--------------------------------------------------------------------------------
/资源/数据表/stm32l051c6.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/stm32l051c6.pdf
--------------------------------------------------------------------------------
/资源/数据表/tps61020.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/tps61020.pdf
--------------------------------------------------------------------------------
/资源/数据表/备选/DS3231M.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/备选/DS3231M.pdf
--------------------------------------------------------------------------------
/资源/数据表/备选/GDEH029A1-Specificationf2c2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/备选/GDEH029A1-Specificationf2c2.pdf
--------------------------------------------------------------------------------
/资源/数据表/备选/SMD_AAA_1022.PDF:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/备选/SMD_AAA_1022.PDF
--------------------------------------------------------------------------------
/资源/数据表/备选/tps61099.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/备选/tps61099.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/Low-Power Modes on the STM32L0 Series - Microcontroller - eewiki.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/Low-Power Modes on the STM32L0 Series - Microcontroller - eewiki.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/STM32_VREF.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/STM32_VREF.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/Sensirion_Humidity_Design_Guide_V1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/Sensirion_Humidity_Design_Guide_V1.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/Sensirion_Humidity_Sensors_SHT3x_Application_Note_Alert_Mode_DIS.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/Sensirion_Humidity_Sensors_SHT3x_Application_Note_Alert_Mode_DIS.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/dm00104451-cortexm0-programming-manual-for-stm32l0-stm32g0-stm32wl-and-stm32wb-series-stmicroelectronics.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/dm00104451-cortexm0-programming-manual-for-stm32l0-stm32g0-stm32wl-and-stm32wb-series-stmicroelectronics.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/dm00108282-ultralowpower-stm32l0x1-advanced-armbased-32bit-mcus-stmicroelectronics.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/dm00108282-ultralowpower-stm32l0x1-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/dm00114897-stm32l051x68-device-limitations-stmicroelectronics.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/dm00114897-stm32l051x68-device-limitations-stmicroelectronics.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/dm00315319-stm32-gpio-configuration-for-hardware-settings-and-lowpower-consumption-stmicroelectronics.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/dm00315319-stm32-gpio-configuration-for-hardware-settings-and-lowpower-consumption-stmicroelectronics.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/slva139 battery.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/slva139 battery.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/slva194.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/slva194.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/slva315 battery.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/slva315 battery.pdf
--------------------------------------------------------------------------------
/资源/数据表/应用手册/slva387.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/izilzty/L051K8U6_EPD_CLOCK/6b43526449391cf5350c5e5ec1e467e0da3568ff/资源/数据表/应用手册/slva387.pdf
--------------------------------------------------------------------------------