📄 spt6608.h
字号:
#ifndef __SPT6608_H__
#define __SPT6608_H__
//#include "SPT01.h"
//#include "SPT01.h"
#define U16 unsigned int
// ========================================================================= //
// File Name : SPT6608.h //
// Description : SPT6608 register definitions //
// Processor : SPT6608 //
// Revision : v1.00, 2007-07-26 //
// ========================================================================= //
//***************************************************************************//
// Register definitions //
//***************************************************************************//
//***************************************************************************//
// IO port control registers
//***************************************************************************//
typedef union
{
U16 Word;
struct
{
U16 bit0 : 1; //LSB
U16 bit1 : 1;
U16 bit2 : 1;
U16 bit3 : 1;
U16 bit4 : 1;
U16 bit5 : 1;
U16 bit6 : 1;
U16 bit7 : 1;
U16 bit8 : 1;
U16 bit9 : 1;
U16 bit10 : 1;
U16 bit11 : 1;
U16 bit12 : 1;
U16 bit13 : 1;
U16 bit14 : 1;
U16 bit15 : 1; //MSB
}Bits;
struct
{
U16 byte0 : 8; //低字节
U16 byte1 : 8; //高字节
}Byte;
}Gen_Type_Def;
//LCD.c
typedef union
{
struct Bit8Def
{
U16 bitl : 8; //8-Bit
U16 bith : 8; //8-Bit
}Bit8Def;
struct wordfielddef
{
U16 bit : 16;
}WORDFIELDDEF;
}FIELDDEF;
// IOA0~IOA7 can be set as input or output pin by pin.
// Input mode - IOA0~IOA7 provide pull-high resistosrs
// IOA6 & IOA7 provide pull-low resistors
// Output mode - CMOS output
// Wake-up - IOA0~IOA7 all provide wake-up function
#define P_IOA_Data (volatile unsigned int *)0x7000
//R, port A output latch
#define P_IOA_Buf (volatile unsigned int *)0x7001
//R/W, portA direction, 0/1 = I/O
#define P_IOA_Dir (volatile unsigned int *)0x7002
//R/W, portA pull-highs & pull-lows
// b15~b8 = 1 to enable pull-high of IOA7~IOA0
// b7~b6 = 1 to enable pull-low of IOA7~IOA6
#define P_IOA_PullR (volatile unsigned int *)0x7003
//R, latch IO for wakeup
#define P_IOA_Latch (volatile unsigned int *)0x7004
typedef union
{
U16 W;
struct
{
U16 Reserve : 6;
U16 PullLow : 2;
U16 PullHigh : 8;
} B;
} P_IOAE_PullR_Def;
#define U_IOA_PullR ((volatile P_IOAE_PullR_Def *)(0x7003))
// IOB0~IOB7 can be set as input or output pin by pin.
// Input mode - CMOS input (without pulled reisitors)
// Output mode - IOB0~IOB5 are CMOS outputs
// IOB6 & IOB7 are NMOS open-drain
// Wake-up - no wake-up function
//R/W, portB data
#define P_IOB_Data (volatile unsigned int *)0x7005
//R, portB output latch
#define P_IOB_Buf (volatile unsigned int *)0x7006
//R/W, portB direction, 0/1 = I/O
#define P_IOB_Dir (volatile unsigned int *)0x7007
// IOC0~IOC7 can be set as input or output pin by pin.
// Input mode - CMOS input (without pulled reisitors)
// Output mode - IOC0~IOC4 are CMOS outputs
// IOC5 & IOC7 are NMOS open-drain
// Wake-up - IOC0 & IOC1 provide wake-up function
//R/W, portC data
#define P_IOC_Data (volatile unsigned int *)0x7008
//R, portC output latch
#define P_IOC_Buf (volatile unsigned int *)0x7009
//R/W, portC direction
#define P_IOC_Dir (volatile unsigned int *)0x700A
// IOD0~7 can be set as input or output pin by pin.
// Input mode - CMOS input (without pulled reisitors)
// Output mode - IOD0~IOD7 are CMOS outputs
// Wake-up - no wake-up function
//R/W, portD data
#define P_IOD_Data (volatile unsigned int *)0x700B
//R, portD output latch
#define P_IOD_Buf (volatile unsigned int *)0x700C
//R/W, portD direction, 0/1 = I/O
#define P_IOD_Dir (volatile unsigned int *)0x700D
// IOE0~IOE7 can be set as input or output pin by pin.
// Input mode - IOE0~IOE7 provide pull-high resistosrs
// IOE6 & IOE7 provide pull-low resistors
// Output mode - CMOS output
// Wake-up - IOE0~IOE7 all provide wake-up function
//R/W, portE data
#define P_IOE_Data (volatile unsigned int *)0x7050
//R, port E output latch
#define P_IOE_Buf (volatile unsigned int *)0x7051
//R/W, portE direction, 0/1 = I/O
#define P_IOE_Dir (volatile unsigned int *)0x7052
//R/W, portE pull-highs & pull-lows
// b15~b8 = 1 to enable pull-high of IOE7~IOE0
// b7~b6 = 1 to enable pull-low of IOE7~IOE6
#define P_IOE_PullR (volatile unsigned int *)0x7053
//R, latch IO for wakeup
#define P_IOE_Latch (volatile unsigned int *)0x7054
#define U_IOE_PullR ((volatile P_IOAE_PullR_Def *)(0x7053))
// b0,b1, 00 - C0 provide interrupt/wake-up at falling edge
// 01 - C0 provide interrupt/wake-up at rising edge
// 1x - C0 provide interrupt/wake-up at both edges
// b3~b2, 00 - C1 provide interrupt/wake-up at falling edge
// 01 - C1 provide interrupt/wake-up at rising edge
// 1x - C1 provide interrupt/wake-up at both edgex
// b4, 0 - tone output (IOD1) comes from timer A overflow
// 1 - tone output (IOD1) comes from timer B overflow
// b5, 0 - IOD1 is normal I/O
// 1 - IOD1 is tone-output
#define P_IOCD_Ctrl (volatile unsigned int *)0x700E
typedef union
{
U16 W;
struct
{
U16 C0EG : 2;
U16 C1EG : 2;
U16 TMSL : 1;
U16 D1Tone : 1;
U16 Reserve : 10;
} B;
} P_IOCD_Ctrl_Def;
#define U_IOCD_Ctrl ((volatile P_IOCD_Ctrl_Def *)(0x700E))
//***************************************************************************//
// Interrupt & Wake-Up
//***************************************************************************//
typedef union
{
U16 W;
struct
{
U16 RingDet : 1;
U16 IOAE : 1;
U16 TMAOC : 1;
U16 TMBOC : 1;
U16 T32KHz : 1;
U16 T2KHz : 1;
U16 T128Hz : 1;
U16 T8Hz : 1;
U16 IOC0INT : 1;
U16 IOC1INT : 1;
U16 LineInt : 1;
U16 UART : 1;
U16 Reserve : 4;
} B;
} P_Int_Def;
// write 0/1 - disable/enable interrupt
// read 0/1 - interrupt is disabled/enabled
#define P_Int (volatile unsigned int *)0x7010
#define U_Int ((volatile P_Int_Def *)(0x7010))
// write 1 - clear happened interrupt flag
// read 1 - interrupt is happened
#define P_IntClr (volatile unsigned int *)0x7011
#define U_IntClr ((volatile P_Int_Def *)(0x7011))
typedef union
{
U16 W;
struct
{
U16 RingDet : 1;
U16 IOAE : 1;
U16 TMAOC : 1;
U16 TMBOC : 1;
U16 T32KHz : 1;
U16 T2KHz : 1;
U16 T128Hz : 1;
U16 T8Hz : 1;
U16 IOC0WP : 1;
U16 IOC1WP : 1;
U16 LineWP : 1;
U16 Reserve : 5;
} B;
} P_WakeUp_Def;
// write 0/1 - disable/enable wake-up
// read 0/1 - wake-up is disabled/enabled
#define P_WakeUp (volatile unsigned int *)0x7012
#define U_WakeUp ((volatile P_WakeUp_Def *)(0x7012))
// write 1 - clear happened wake-up flag
// read 1 - wake-up is happened
#define P_WakeUpClr (volatile unsigned int *)0x7013
#define U_WakeUpClr ((volatile P_WakeUp_DEF *)(0x7013))
// vector = FFF8
#define B_Irq0 0x0001
#define B_RiInt 0x0001
// vector = FFF9
#define B_Irq1 0x0002
#define B_IoaeInt 0x0002
// vector = FFFA
#define B_Irq2 0x0004
#define B_TmrAInt 0x0004
// vector = FFFB
#define B_Irq3 0x0008
#define B_TmrBInt 0x0008
// vector = FFFC
#define B_Irq4 0x0010
#define B_T32KHzInt 0x0010
#define B_8KHzInt 0x0010
// vector = FFFD
#define B_Irq5 0x0020
#define B_T2KHzInt 0x0020
#define B_1KHzInt 0x0020
#define B_512HzInt 0x0020
// vector = FFFE
#define B_Irq6 0x0040
#define B_T128HzInt 0x0040
#define B_Irq7 0x0080
// vector = FFFF
#define B_T8HzInt 0x0080
#define B_2HzInt 0x0080
// vector = FFF8
#define B_Ioc0Int 0x0100
// vector = FFF6
#define B_Ioc1Int 0x0200
// vector = FFF8
#define B_LineInt 0x0400
// vector = FFF6
#define B_URATInt 0x0800
// vector = FFF6
#define B_IrDAInt 0x0800
//-------------------------------*/
// R/W, b7~b0=1 to enable IOA7~0 wake-up
#define P_IoaWakeUp (volatile unsigned int *)0x7014
// R/W, b7~b0=1 to enable IOE7~0 wake-up
#define P_IoeWakeUp (volatile unsigned int *)0x7055
//-------------------------------*/
// System Clock */
//-------------------------------*/
// b2~b0: CPU Operating Clock Select
// 000 - Fosc
// 001 - Fosc/2
// 010 - Fosc/4
// 011 - Fosc/8 (default)
// 100 - Fosc/8
// 101 - Fosc/8
// 110 - Fosc/8
// 111 - Stop/Sleep
// b7: 0 - Fosc= Low-Speed Mode
// 1 - Fosc= High-Speed Mode
typedef union
{
U16 W;
struct
{
U16 SCK : 3;
U16 Reserve1 : 4;
U16 Mode : 1;
U16 Reserve2 : 8;
} B;
} P_SystemClock_Def;
#define P_SystemClock (volatile unsigned int *)0x7015
#define U_SystemClock ((volatile P_SystemClock_Def *)(0x7015))
#define B_FoscDivBy1 0x0000
#define B_FoscDivBy2 0x0001
#define B_FoscDivBy4 0x0002
#define B_FoscDivBy8 0x0003
#define B_Sleep 0x0007
#define B_NormalCpuClock B_FoscDivBy4
#define B_Div10 0x0080
// write 16-bit (0x55AA) value to reset watch dog; period = 2sec
#define P_Watchdog_Clr (volatile unsigned int *)0x7016
//-------------------------------*/
// Time Base */
//-------------------------------*/
// b15: enable 32768
// b14: weak/strong mode
// b7~b6: T32KHzS
// 00 - 4KHz
// 01 - 8KHz
// 10 - 16KHz
// 11 - 32KHz
// b5~b4: T2KHz
// 00 - 256Hz
// 01 - 512Hz
// 10 - 1KHz
// 11 - 2KHz
// b3~b2: T128HzS
// 00 - 16Hz
// 01 - 32Hz
// 10 - 64Hz
// 11 - 128Hz
// b1~b0: T8HzS
// 00 - 1Hz
// 01 - 2Hz
// 10 - 4Hz
// 11 - 8Hz
// Time Base, generated by 32768Hz, is a combination of frequency selection
// for timers and interrupt.
typedef union
{
U16 W;
struct
{
U16 T8S : 2;
U16 T128S : 2;
U16 T2KS : 2;
U16 T32KS : 2;
U16 Reserve : 6;
U16 Strong : 1;
U16 Enable : 1;
} B;
} P_TimeBaseSet_Def;
#define P_TimeBaseSet (volatile unsigned int *)0x7018
#define U_TimeBaseSet ((volatile P_TimeBaseSet_Def *)(0x7018))
#define TimeBaseSetDiv1 3
#define TimeBaseSetDiv2 2
#define TimeBaseSetDiv4 1
#define TimeBaseSetDiv8 0
#define B_Enable32768 0x8000
#define T8Set 0x10
#define T128Set 0x20
#define T2KSet 0x40
#define T32KSet 0x80
// After powering on, set 32768 at strong mode
#define B_Strong32768 0x4000
#define B_1Hz 0x0000
#define B_2Hz 0x0001
#define B_4Hz 0x0002
#define B_8Hz 0x0003
#define B_16Hz 0x0000
#define B_32Hz 0x0004
#define B_64Hz 0x0008
#define B_128Hz 0x000C
#define B_256Hz 0x0000
#define B_512Hz 0x0010
#define B_1KHz 0x0020
#define B_2KHz 0x0030
#define B_4KHz 0x0000
#define B_8KHz 0x0040
#define B_16KHz 0x0080
#define B_32KHz 0x00C0
//-------------------------------*/
// Timer A & B */
//-------------------------------*/
// Writing a value of N to P_TimerA_Data or P_TimerB_Data and selecting an
// appropriate clock sources, the timer will count up from N, N+1, N+2, ....
// ,FFFE, FFFF. After the timer reaches 'FFFF', and INT signal is generated
// and is sent to INT controller for processing. At the same time, N will be
// reloaded into timer and count up again.
// b15: TMA_En
// 0 - disable 111 - T8Hz (1Hz,2Hz,4Hz,8Hz)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -