opt: sfr macros for stc8g
This commit is contained in:
parent
d6c819430d
commit
0f08cb1f41
@ -23,30 +23,31 @@
|
||||
#define ADC_SamplingFinished() (ADC_CONTR & (0x01 << 5))
|
||||
#define ADC_ClearInterrupt() SFR_RESET(ADC_CONTR, 5)
|
||||
#define ADC_SetPWMTriggerState(__STATE__) SFR_ASSIGN(ADC_CONTR, 4, __STATE__)
|
||||
|
||||
/**
|
||||
* ADC input channels selection
|
||||
* Set PxM0/PxM1 to high-impedance input for selected I/O port, and set PxIE
|
||||
* to shutdown digital input if you want to enable ADC in powerdown mode
|
||||
*
|
||||
* STC8H8K64U
|
||||
* STC8H3K64S4 STC8H2K64T STC8H4K64TLCD
|
||||
* STC8H1K28: STC8H1K08 STC8H3K64S2 STC8H4K64TLR STC8H4K64LCD
|
||||
* 0000 P1.0/ADC0 P1.0/ADC0 P1.0/ADC0 P1.0/ADC0 P1.0/ADC0
|
||||
* 0001 P1.1/ADC1 P1.1/ADC1 P1.1/ADC1 P1.1/ADC1 P1.1/ADC1
|
||||
* 0010 P1.2/ADC2 N/A P1.2/ADC2 P5.4/ADC2 P5.4/ADC2
|
||||
* 0011 P1.3/ADC3 N/A N/A P1.3/ADC3 P1.3/ADC3
|
||||
* 0100 P1.4/ADC4 N/A N/A P1.4/ADC4 P1.4/ADC4
|
||||
* 0101 P1.5/ADC5 N/A N/A P1.5/ADC5 P1.5/ADC5
|
||||
* 0110 P1.6/ADC6 N/A P1.6/ADC6 P1.6/ADC6 P6.2/ADC6
|
||||
* 0111 P1.7/ADC7 N/A P1.7/ADC7 P1.7/ADC7 P6.3/ADC7
|
||||
* 1000 P0.0/ADC8 P3.0/ADC8 P0.0/ADC8 P0.0/ADC8 P0.0/ADC8
|
||||
* 1001 P0.1/ADC9 P3.1/ADC9 P0.1/ADC9 P0.1/ADC9 P0.1/ADC9
|
||||
* 1010 P0.2/ADC10 P3.2/ADC10 P0.2/ADC10 P0.2/ADC10 P0.2/ADC10
|
||||
* 1011 P0.3/ADC11 P3.3/ADC11 P0.3/ADC11 P0.3/ADC11 P0.3/ADC11
|
||||
* 1100 N/A P3.4/ADC12 P0.4/ADC12 P0.4/ADC12 P0.4/ADC12
|
||||
* 1101 N/A P3.5/ADC13 P0.5/ADC13 P0.5/ADC13 P0.5/ADC13
|
||||
* 1110 N/A P3.6/ADC14 P0.6/ADC14 P0.6/ADC14 P0.6/ADC14
|
||||
* 1111 Internal 1.19V Internal 1.19V Internal 1.19V Internal 1.19V Internal 1.19V
|
||||
* STC8H3K64S4 STC8H2K64T STC8H4K64TLCD STC8G1K08 STC8G2K64S4
|
||||
* STC8H1K28: STC8H1K08 STC8H3K64S2 STC8H4K64TLR STC8H4K64LCD STC8G1K08A STC8G1K08T STC8G2K64S2
|
||||
* 0000 P1.0/ADC0 P1.0/ADC0 P1.0/ADC0 P1.0/ADC0 P1.0/ADC0 P3.0/ADC0 P1.0/ADC0 P1.0/ADC0
|
||||
* 0001 P1.1/ADC1 P1.1/ADC1 P1.1/ADC1 P1.1/ADC1 P1.1/ADC1 P3.1/ADC1 P1.1/ADC1 P1.1/ADC1
|
||||
* 0010 P1.2/ADC2 N/A P1.2/ADC2 P5.4/ADC2 P5.4/ADC2 P3.2/ADC2 P1.2/ADC2 P1.2/ADC2
|
||||
* 0011 P1.3/ADC3 N/A N/A P1.3/ADC3 P1.3/ADC3 P3.3/ADC3 P1.3/ADC3 P1.3/ADC3
|
||||
* 0100 P1.4/ADC4 N/A N/A P1.4/ADC4 P1.4/ADC4 P5.4/ADC4 P1.4/ADC4 P1.4/ADC4
|
||||
* 0101 P1.5/ADC5 N/A N/A P1.5/ADC5 P1.5/ADC5 P5.5/ADC5 P1.5/ADC5 P1.5/ADC5
|
||||
* 0110 P1.6/ADC6 N/A P1.6/ADC6 P1.6/ADC6 P6.2/ADC6 N/A P1.6/ADC6 P1.6/ADC6
|
||||
* 0111 P1.7/ADC7 N/A P1.7/ADC7 P1.7/ADC7 P6.3/ADC7 N/A P1.7/ADC7 P1.7/ADC7
|
||||
* 1000 P0.0/ADC8 P3.0/ADC8 P0.0/ADC8 P0.0/ADC8 P0.0/ADC8 N/A P3.0/ADC8 P0.0/ADC8
|
||||
* 1001 P0.1/ADC9 P3.1/ADC9 P0.1/ADC9 P0.1/ADC9 P0.1/ADC9 N/A P3.1/ADC9 P0.1/ADC9
|
||||
* 1010 P0.2/ADC10 P3.2/ADC10 P0.2/ADC10 P0.2/ADC10 P0.2/ADC10 N/A P3.2/ADC10 P0.2/ADC10
|
||||
* 1011 P0.3/ADC11 P3.3/ADC11 P0.3/ADC11 P0.3/ADC11 P0.3/ADC11 N/A P3.3/ADC11 P0.3/ADC11
|
||||
* 1100 N/A P3.4/ADC12 P0.4/ADC12 P0.4/ADC12 P0.4/ADC12 N/A P3.4/ADC12 P0.4/ADC12
|
||||
* 1101 N/A P3.5/ADC13 P0.5/ADC13 P0.5/ADC13 P0.5/ADC13 N/A P3.5/ADC13 P0.5/ADC13
|
||||
* 1110 N/A P3.6/ADC14 P0.6/ADC14 P0.6/ADC14 P0.6/ADC14 N/A P3.6/ADC14 P0.6/ADC14
|
||||
* 1111 Internal 1.19V voltage reference
|
||||
*/
|
||||
#define ADC_SetChannel(__CHANNEL__) (ADC_CONTR = ADC_CONTR & ~0x0F | ((__CHANNEL__) << 0))
|
||||
|
||||
|
@ -93,7 +93,7 @@
|
||||
#endif
|
||||
|
||||
#if (__CONF_MCU_MODEL == MCU_MODEL_STC8A8K64D4)
|
||||
#include "fw_reg_stc8a.h"
|
||||
#define __CONF_MCU_TYPE_STC8A8K64D4 1
|
||||
#elif (__CONF_MCU_MODEL == MCU_MODEL_STC8G1K04 ) || \
|
||||
(__CONF_MCU_MODEL == MCU_MODEL_STC8G1K08 ) || \
|
||||
(__CONF_MCU_MODEL == MCU_MODEL_STC8G1K12 ) || \
|
||||
@ -103,8 +103,8 @@
|
||||
(__CONF_MCU_MODEL == MCU_MODEL_STC8G2K48 ) || \
|
||||
(__CONF_MCU_MODEL == MCU_MODEL_STC8G2K60 ) || \
|
||||
(__CONF_MCU_MODEL == MCU_MODEL_STC8G2K64 )
|
||||
#include "fw_reg_stc8g.h"
|
||||
#include "fw_cid_stc8g.h"
|
||||
#define __CONF_MCU_TYPE_STC8G 1
|
||||
|
||||
#elif (__CONF_MCU_MODEL == MCU_MODEL_STC8H1K08 ) || \
|
||||
(__CONF_MCU_MODEL == MCU_MODEL_STC8H1K12 ) || \
|
||||
(__CONF_MCU_MODEL == MCU_MODEL_STC8H1K16 ) || \
|
||||
@ -136,6 +136,15 @@
|
||||
(__CONF_MCU_MODEL == MCU_MODEL_STC8H4K64TLR ) || \
|
||||
(__CONF_MCU_MODEL == MCU_MODEL_STC8H4K64TLCD ) || \
|
||||
(__CONF_MCU_MODEL == MCU_MODEL_STC8H4K64LCD )
|
||||
#define __CONF_MCU_TYPE_STC8H 1
|
||||
#endif
|
||||
|
||||
#if __CONF_MCU_TYPE_STC8A8K64D4
|
||||
#include "fw_reg_stc8a.h"
|
||||
#elif __CONF_MCU_TYPE_STC8G
|
||||
#include "fw_reg_stc8g.h"
|
||||
#include "fw_cid_stc8g.h"
|
||||
#elif __CONF_MCU_TYPE_STC8H
|
||||
#include "fw_reg_stc8h.h"
|
||||
#include "fw_cid_stc8h.h"
|
||||
#endif
|
||||
|
@ -53,9 +53,51 @@ typedef enum
|
||||
#define EXTI_VectTimer3 19
|
||||
#define EXTI_VectTimer4 20
|
||||
#define EXTI_VectCMP 21
|
||||
#define EXTI_VectPWM 22
|
||||
#define EXTI_VectPWMFD 23
|
||||
#define EXTI_VectI2C 24
|
||||
#define EXTI_VectTKSU 35
|
||||
|
||||
#if __CONF_MCU_TYPE_STC8G
|
||||
#define EXTI_VectPWM0 22
|
||||
#define EXTI_VectPWM0FD 23
|
||||
#define EXTI_VectPWM1 28
|
||||
#define EXTI_VectPWM2 29
|
||||
#define EXTI_VectPWM3 30
|
||||
#define EXTI_VectPWM4 31
|
||||
#define EXTI_VectPWM5 32
|
||||
#define EXTI_VectPWM2FD 33
|
||||
#define EXTI_VectPWM4FD 34
|
||||
|
||||
#elif __CONF_MCU_TYPE_STC8H
|
||||
#define EXTI_VectUSB 25
|
||||
#define EXTI_VectPWMA 26
|
||||
#define EXTI_VectPWMB 27
|
||||
|
||||
#define EXTI_VectRTC 36
|
||||
|
||||
#define EXTI_VectP0 37
|
||||
#define EXTI_VectP1 38
|
||||
#define EXTI_VectP2 39
|
||||
#define EXTI_VectP3 40
|
||||
#define EXTI_VectP4 41
|
||||
#define EXTI_VectP5 42
|
||||
#define EXTI_VectP6 43
|
||||
#define EXTI_VectP7 44
|
||||
|
||||
#define EXTI_VectDMA_M2M 47
|
||||
#define EXTI_VectDMA_ADC 48
|
||||
#define EXTI_VectDMA_SPI 49
|
||||
#define EXTI_VectDMA_UR1T 50
|
||||
#define EXTI_VectDMA_UR1R 51
|
||||
#define EXTI_VectDMA_UR2T 52
|
||||
#define EXTI_VectDMA_UR2R 53
|
||||
#define EXTI_VectDMA_UR3T 54
|
||||
#define EXTI_VectDMA_UR3R 55
|
||||
#define EXTI_VectDMA_UR4T 56
|
||||
#define EXTI_VectDMA_UR4R 57
|
||||
#define EXTI_VectDMA_LCM 58
|
||||
#define EXTI_VectLCM 59
|
||||
|
||||
#endif
|
||||
|
||||
#define EXTI_Global_SetIntState(__STATE__) SBIT_ASSIGN(EA, __STATE__)
|
||||
#define EXTI_Timer0_SetIntState(__STATE__) SBIT_ASSIGN(ET0, __STATE__)
|
||||
|
@ -34,8 +34,10 @@ typedef enum
|
||||
GPIO_Port_3 = 3U,
|
||||
GPIO_Port_4 = 4U,
|
||||
GPIO_Port_5 = 5U,
|
||||
#if __CONF_MCU_TYPE_STC8H
|
||||
GPIO_Port_6 = 6U,
|
||||
GPIO_Port_7 = 7U,
|
||||
#endif
|
||||
} GPIO_Port_t;
|
||||
|
||||
typedef enum
|
||||
@ -99,6 +101,7 @@ typedef enum
|
||||
P5M1 = P5M1 & ~(__PINS__) | (((__MODE__) & 0x02)? (__PINS__) : 0x00); \
|
||||
} while(0)
|
||||
|
||||
#if __CONF_MCU_TYPE_STC8H
|
||||
#define GPIO_P6_SetMode(__PINS__, __MODE__) do { \
|
||||
P6M0 = P6M0 & ~(__PINS__) | (((__MODE__) & 0x01)? (__PINS__) : 0x00); \
|
||||
P6M1 = P6M1 & ~(__PINS__) | (((__MODE__) & 0x02)? (__PINS__) : 0x00); \
|
||||
@ -108,6 +111,7 @@ typedef enum
|
||||
P7M0 = P7M0 & ~(__PINS__) | (((__MODE__) & 0x01)? (__PINS__) : 0x00); \
|
||||
P7M1 = P7M1 & ~(__PINS__) | (((__MODE__) & 0x02)? (__PINS__) : 0x00); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#define GPIO_SetPullUp(__PORT__, __PINS__, __STATE__) do { \
|
||||
P_SW2 = 0x80; \
|
||||
|
@ -283,7 +283,7 @@ SFR(RSTCFG, 0xFF);
|
||||
#define MCLKOCR (*(unsigned char volatile __XDATA *)0xfe05)
|
||||
#define IRCDB (*(unsigned char volatile __XDATA *)0xfe06)
|
||||
#define X32KCR (*(unsigned char volatile __XDATA *)0xfe08)
|
||||
|
||||
#define PxPU 0xfe10
|
||||
#define P0PU (*(unsigned char volatile __XDATA *)0xfe10)
|
||||
#define P1PU (*(unsigned char volatile __XDATA *)0xfe11)
|
||||
#define P2PU (*(unsigned char volatile __XDATA *)0xfe12)
|
||||
@ -292,6 +292,7 @@ SFR(RSTCFG, 0xFF);
|
||||
#define P5PU (*(unsigned char volatile __XDATA *)0xfe15)
|
||||
#define P6PU (*(unsigned char volatile __XDATA *)0xfe16)
|
||||
#define P7PU (*(unsigned char volatile __XDATA *)0xfe17)
|
||||
#define PxNCS 0xfe18
|
||||
#define P0NCS (*(unsigned char volatile __XDATA *)0xfe18)
|
||||
#define P1NCS (*(unsigned char volatile __XDATA *)0xfe19)
|
||||
#define P2NCS (*(unsigned char volatile __XDATA *)0xfe1a)
|
||||
@ -300,6 +301,7 @@ SFR(RSTCFG, 0xFF);
|
||||
#define P5NCS (*(unsigned char volatile __XDATA *)0xfe1d)
|
||||
#define P6NCS (*(unsigned char volatile __XDATA *)0xfe1e)
|
||||
#define P7NCS (*(unsigned char volatile __XDATA *)0xfe1f)
|
||||
#define PxSR 0xfe20
|
||||
#define P0SR (*(unsigned char volatile __XDATA *)0xfe20)
|
||||
#define P1SR (*(unsigned char volatile __XDATA *)0xfe21)
|
||||
#define P2SR (*(unsigned char volatile __XDATA *)0xfe22)
|
||||
@ -308,6 +310,7 @@ SFR(RSTCFG, 0xFF);
|
||||
#define P5SR (*(unsigned char volatile __XDATA *)0xfe25)
|
||||
#define P6SR (*(unsigned char volatile __XDATA *)0xfe26)
|
||||
#define P7SR (*(unsigned char volatile __XDATA *)0xfe27)
|
||||
#define PxDR 0xfe28
|
||||
#define P0DR (*(unsigned char volatile __XDATA *)0xfe28)
|
||||
#define P1DR (*(unsigned char volatile __XDATA *)0xfe29)
|
||||
#define P2DR (*(unsigned char volatile __XDATA *)0xfe2a)
|
||||
@ -316,6 +319,7 @@ SFR(RSTCFG, 0xFF);
|
||||
#define P5DR (*(unsigned char volatile __XDATA *)0xfe2d)
|
||||
#define P6DR (*(unsigned char volatile __XDATA *)0xfe2e)
|
||||
#define P7DR (*(unsigned char volatile __XDATA *)0xfe2f)
|
||||
#define PxIE 0xfe30
|
||||
#define P0IE (*(unsigned char volatile __XDATA *)0xfe30)
|
||||
#define P1IE (*(unsigned char volatile __XDATA *)0xfe31)
|
||||
#define P2IE (*(unsigned char volatile __XDATA *)0xfe32)
|
||||
|
@ -25,6 +25,10 @@
|
||||
* SPI MOSI -> 2 15 15(P34)
|
||||
* SPI MISO -> 3 14 14(P33)
|
||||
* SPI CLK -> 4 13 13(P32)
|
||||
*
|
||||
* The ports for STC8G1K08-8Pin, STC8G1K08A are different:
|
||||
* SS MO MI SCLK
|
||||
* 00 - P5.5 P5.4 P3.3 P3.2, 01/10/11 - n/a
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
@ -32,6 +32,12 @@ typedef enum
|
||||
UART1_BaudSource_Timer2 = 0x01,
|
||||
} UART1_BaudSource_t;
|
||||
|
||||
/**
|
||||
* Alternative ports
|
||||
*
|
||||
* The ports for STC8G1K08-8Pin and STC8G1K08A are different:
|
||||
* 00 - P3.0 P3.1, 01 - P3.2 P3.3, 10 - P5.4 P5.5, 11 - n/a
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
UART1_AlterPort_P30_P31 = 0x00,
|
||||
|
Loading…
Reference in New Issue
Block a user