📄 lpc_syscontrol.h
字号:
#ifndef __LPC_SYSCONTROL_H
#define __LPC_SYSCONTROL_H
/***********************************************************************
* BU MMS China, Philips Semiconductor Software Support
* Embest info&Tech Co. Software Support
*---------------------------------------------------------------------------
* The software is delivered "AS IS" without warranty or condition of any
* kind, either express, implied or statutory. Everybody can use it as
* it is opened and without copyright. We will not take any law responsibility
* for any problem produced by using this software.
*---------------------------------------------------------------------------
* File name: LPC_SysControl.h
* Description: Define system control block structure and relative micro
*
* History:
* 1. Date: Aug 17, 2004
* Author: Shawn Zhang
* Description: Create
*
* $Revision: 1.0 $
**********************************************************************/
#include "LPC_Base.h"
#include "LPC_Type.h"
#define IRQ_FLAG 0x80
/* Fosc range: 10MHz ~ 25MHz */
#define Fosc_MIN 10000000L
#define Fosc_MAX 25000000L
/* Fcclk range: 10MHz ~ MCU allowed frequency */
#define Fcclk_MIN 10000000L
#define Fcclk_MAX 60000000L // 2119/2129/2292/2294: 60MHz
/* Fcco range: 156MHz ~ 320MHz */
#define Fcco_MIN 156000000L
#define Fcco_MAX 320000000L
#define PLLFEED_DATA1 0xAA
#define PLLFEED_DATA2 0x55
/* PLL PLLCON register bit descriptions */
#define PLLCON_ENABLE_BIT 0
#define PLLCON_CONNECT_BIT 1
/* PLL PLLSTAT register bit descriptions */
#define PLLSTAT_ENABLE_BIT 8
#define PLLSTAT_CONNECT_BIT 9
#define PLLSTAT_LOCK_BIT 10
/* PM Peripheral Type */
#define PC_TIMER0 0x2
#define PC_TIMER1 0x4
#define PC_UART0 0x8
#define PC_UART1 0x10
#define PC_PWM0 0x20
#define PC_I2C 0x80
#define PC_SPI0 0x100
#define PC_RTC 0x200
#define PC_SPI1 0x400
#define PC_EMC 0x800
#define PC_AD 0x1000
#define PC_CAN0 0x2000
#define PC_CAN1 0x4000
#define PC_CAN2 0x8000
#define PC_CAN3 0x10000
/* GPIO port */
#define P0 0x1
#define P1 0x2
#define P2 0x4
#define P3 0x8
#define P4 0x10
#define P5 0x20
#define P6 0x40
#define P7 0x80
#define P8 0x100
#define P9 0x200
#define P10 0x400
#define P11 0x800
#define P12 0x1000
#define P13 0x2000
#define P14 0x4000
#define P15 0x8000
#define P16 0x10000
#define P17 0x20000
#define P18 0x40000
#define P19 0x80000
#define P20 0x100000
#define P21 0x200000
#define P22 0x400000
#define P23 0x800000
#define P24 0x1000000
#define P25 0x2000000
#define P27 0x8000000
#define P28 0x10000000
#define P29 0x20000000
#define P30 0x40000000
#define P31 0x80000000
/* SWI Number */
#define SWI_DISINT 0
#define SWI_RESTORE 1
/* Memory Mapping Control Mode */
typedef enum {
BOOT_LOADER = 0,
USE_FLASH,
USE_RAM,
USE_EXTMEM
} LPC_RemapMode_t;
/* Memory Accelerator Module Operating Mode */
typedef enum {
VPBDIV4 = 0, // Pclk = 1/4 Pcclk
VPBDIV1, // Pclk = Pcclk
VPBDIV2 // Pclk = 1/2 Pcclk
} LPC_VPBDiv_t;
/* Memory Accelerator Module Operating Mode */
typedef enum {
MAM_PARTIALLY = 1,
MAM_FULL
} LPC_MAMMode_t;
/* Power Manager Mode */
typedef enum {
PM_STANDARD = 0,
PM_IDLE,
PM_POWERDOWN
} LPC_PMMode_t;
/* External interrupt trigger type */
typedef enum {
LEVEL_LOW = 0,
LEVEL_HIGH,
EDGE_RISING,
EDGE_FALLING
} LPC_EXTINTTriggerType_t;
/* Ext-Int Device number */
typedef enum {
EXTINT0 = 0,
EXTINT1,
EXTINT2,
EXTINT3
} LPC_EXTINT_Channel_t;
/* MAM fetch cycles
SysClock<20MHz: No MAM
20MHz<SysClock<40MHz: suggest 2 cycle
40MHz<SysClock: suggest 3 cycle */
typedef enum {
MAMDisable,
MAMAuto,
MAMManual
} LPC_MAMSetting_t;
typedef enum {
MAMCycle1 = 1,
MAMCycle2,
MAMCycle3,
MAMCycle4,
MAMCycle5,
MAMCycle6,
MAMCycle7
} LPC_MAMCycle_t;
// When choosing 'MAMManual', this value is valid, otherwise set NULL.
typedef struct {
LPC_MAMMode_t Mode;
LPC_MAMCycle_t Cycle;
} LPC_MAMConfig_t;
typedef struct {
unsigned long Fosc; // Crystal Oscillator Frequency
unsigned long Fcclk; // PLL output frequency (also processor clock frequency)
unsigned long Fpclk; // Peripheral frequency
LPC_RemapMode_t RemapMode;
LPC_VPBDiv_t VPBDivider;
LPC_MAMSetting_t MAMSetting;
LPC_MAMConfig_t MAMConfig;
} LPC_SysControl_Config_t;
/* GPIO Device number */
typedef enum {
GPIO0 = 0,
GPIO1,
GPIO2,
GPIO3
} LPC_GPIO_Channel_t;
/* GPIO Direction Mode */
typedef enum {
INPUT = 0,
OUTPUT
} LPC_GPIO_DirectionMode_t;
/* Declare API functions */
int SYS_Init (unsigned long Fosc, unsigned long Fcclk,
LPC_VPBDiv_t VPBDivider,
LPC_RemapMode_t RemapMode,
LPC_MAMSetting_t MAMSetting,
LPC_MAMConfig_t *pMAMConfig);
lpc_uint32 SYS_GetFpclk (void);
lpc_uint32 SYS_GetFcclk (void);
void PM_SetMode (LPC_PMMode_t Mode);
void PM_OpenPeripheral (lpc_uint32 DevType);
void PM_ClosePeripheral (lpc_uint32 DevType);
void EXTINT_SetTriggerType (LPC_EXTINT_Channel_t ExtIntNum, LPC_EXTINTTriggerType_t TriggerType);
void EXTINT_ClearInt (LPC_EXTINT_Channel_t ExtIntNum);
void EXTINT_Enable (LPC_EXTINT_Channel_t ExtIntNum);
void EXTINT_Disable (LPC_EXTINT_Channel_t ExtIntNum);
void EXTINT_EnableWakeup (LPC_EXTINT_Channel_t ExtIntNum);
void EXTINT_DisableWakeup (LPC_EXTINT_Channel_t ExtIntNum);
int GPIO_SetDirectionMode (LPC_GPIO_Channel_t DevNum, unsigned long PortNum,
LPC_GPIO_DirectionMode_t DirectionMode);
int GPIO_TurnOn (LPC_GPIO_Channel_t DevNum, unsigned long PortNum);
int GPIO_TurnOff (LPC_GPIO_Channel_t DevNum, unsigned long PortNum);
bool GPIO_CheckOn (LPC_GPIO_Channel_t DevNum, unsigned long PortNum);
/*************************************************************************
* Function Name: disable_IRQ
* Parameters:
* Return: unsigned long
* Description: Disable IRQ and return previous state of flag I
*
*************************************************************************/
extern unsigned long disable_IRQ(void);
/*************************************************************************
* Function Name: restore_IRQ
* Parameters: unsigned long IFlag
* Return: void
* Description: Restore I flag state
*
*************************************************************************/
extern void restore_IRQ(unsigned long IFlag);
#endif //__LPC_SYSCONTROL_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -