ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
fw_rcc.h
Go to the documentation of this file.
1// Copyright 2021 IOsetting <iosetting(at)outlook.com>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef ___FW_RCC_H___
16#define ___FW_RCC_H___
17
18#include "fw_conf.h"
19#include "fw_types.h"
20
21typedef enum
22{
23 RCC_SYSCLKSource_HSI = 0x00, /* Internal high speed RC osc */
24 RCC_SYSCLKSource_HSE = 0x01, /* External high speed osc */
25 RCC_SYSCLKSource_LSE = 0x02, /* External 32KHz osc */
26 RCC_SYSCLKSource_LSI = 0x03, /* Internal 32KHz RC osc */
28
29typedef enum
30{
31 RCC_LowVoltResetPinAF_IO = 0x00, /* P5.4 as GPIO */
32 RCC_LowVoltResetPinAF_Reset = 0x01, /* P5.4 as RESET */
34
45typedef enum
46{
52
53#define RCC_SetSYSCLKSource(__SOURCE__) do { \
54 SFRX_ON(); \
55 (CKSEL) = (CKSEL) & ~(0x03) | (__SOURCE__); \
56 SFRX_OFF(); \
57 } while(0)
58
59#define RCC_SetCLKDivider(__DIV__) do {SFRX_ON(); CLKDIV = (__DIV__ & 0xFF); SFRX_OFF();} while(0)
60#define RCC_SetPowerDownMode(__STATE__) SFR_ASSIGN(PCON, 1, __STATE__)
61#define RCC_SetIdleMode(__STATE__) SFR_ASSIGN(PCON, 0, __STATE__)
62#define RCC_SetPowerDownWakeupTimerState(__STATE__) SFR_ASSIGN(WKTCH, 7, __STATE__)
63#define RCC_SetPowerDownWakeupTimerCountdown(__15BIT_COUNT__) do { \
64 WKTCH = WKTCH & ~(0x7F) | (__15BIT_COUNT__ >> 8); \
65 WKTCL = (__15BIT_COUNT__ & 0xFF); \
66 }while(0)
67
68#define RCC_SetLowVoltResetState(__STATE__) SFR_ASSIGN(RSTCFG, 6, __STATE__)
69#define RCC_SetLowVoltResetPinAF(__PIN_AF__) SFR_ASSIGN(RSTCFG, 4, __PIN_AF__)
70#define RCC_SetLowVoltResetThreshold(__THRESHOLD__) (RSTCFG = RSTCFG & ~(0x03) | (__THRESHOLD__))
71
72
73#endif
RCC_LowVoltResetPinAF_t
Definition: fw_rcc.h:30
@ RCC_LowVoltResetPinAF_Reset
Definition: fw_rcc.h:32
@ RCC_LowVoltResetPinAF_IO
Definition: fw_rcc.h:31
RCC_SYSCLKSource_t
Definition: fw_rcc.h:22
@ RCC_SYSCLKSource_HSI
Definition: fw_rcc.h:23
@ RCC_SYSCLKSource_LSI
Definition: fw_rcc.h:26
@ RCC_SYSCLKSource_HSE
Definition: fw_rcc.h:24
@ RCC_SYSCLKSource_LSE
Definition: fw_rcc.h:25
RCC_LowVoltThreshold_t
Definition: fw_rcc.h:46
@ RCC_LowVoltThreshold_Low
Definition: fw_rcc.h:48
@ RCC_LowVoltThreshold_Highest
Definition: fw_rcc.h:50
@ RCC_LowVoltThreshold_High
Definition: fw_rcc.h:49
@ RCC_LowVoltThreshold_Lowest
Definition: fw_rcc.h:47