First version under SVN is V4.0.1

This commit is contained in:
Richard Barry 2006-05-02 09:39:15 +00:00
parent 243393860c
commit b6df57c7e3
918 changed files with 269038 additions and 0 deletions

View file

@ -0,0 +1,91 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : 71x_conf.h
* Author : MCD Application Team
* Date First Issued : 16/05/2003
* Description : Library configuration for the ADC12 example
********************************************************************************
* History:
* 16/05/2003 : Created
* 30/11/2004 : V2.0
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __71x_CONF_H
#define __71x_CONF_H
/* Comment the line below to put the library in release mode */
//#define DEBUG
//#define inline inline
//#define USE_SERIAL_PORT
//#define USE_UART0
// Main Oscillator Frequency value = 4 Mhz
#define RCCU_Main_Osc 4000000
/* Comment the lines below corresponding to unwanted peripherals */
//#define _ADC12
//#define _APB
//#define _APB1
//#define _APB2
//#define _BSPI
//#define _BSPI0
//#define _BSPI1
//#define _CAN
//#define _EIC
//#define _EMI
//#define _FLASH
#define _GPIO
#define _GPIO0
#define _GPIO1
#define _GPIO2
//#define _I2C
//#define _I2C0
//#define _I2C1
#define _PCU
#define _RCCU
//#define _RTC
#define _TIM
#define _TIM0
//#define _TIM1
//#define _TIM2
//#define _TIM3
//#define _UART
//#define _UART0
//#define _UART1
//#define _UART2
//#define _UART3
//#define _USB
//#define _WDG
//#define _XTI
//#define _IRQVectors
#endif /* __71x_CONF_H */
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,61 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : 71x_it.h
* Author : MCD Application Team
* Date First Issued : 05/16/2003
* Description : Interrupt handlers
********************************************************************************
* History:
* 30/11/2004 : V2.0
* 14/07/2004 : V1.3
* 01/01/2004 : V1.2
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef _71x_IT_H
#define _71x_IT_H
#include "71x_lib.h"
void Undefined_Handler (void);
void FIQ_Handler (void);
void SWI_Handler (void);
void Prefetch_Handler (void);
void Abort_Handler (void);
void T0TIMI_IRQHandler (void);
void FLASH_IRQHandler (void);
void RCCU_IRQHandler (void);
void RTC_IRQHandler (void);
void WDG_IRQHandler (void);
void XTI_IRQHandler (void);
void USBHP_IRQHandler (void);
void I2C0ITERR_IRQHandler(void);
void I2C1ITERR_IRQHandler(void);
void UART0_IRQHandler (void);
void UART1_IRQHandler (void);
void UART2_IRQHandler (void);
void UART3_IRQHandler (void);
void BSPI0_IRQHandler (void);
void BSPI1_IRQHandler (void);
void I2C0_IRQHandler (void);
void I2C1_IRQHandler (void);
void CAN_IRQHandler (void);
void ADC12_IRQHandler (void);
void T1TIMI_IRQHandler (void);
void T2TIMI_IRQHandler (void);
void T3TIMI_IRQHandler (void);
void HDLC_IRQHandler (void);
void USBLP_IRQHandler (void);
void T0TOI_IRQHandler (void);
void T0OC1_IRQHandler (void);
void T0OC2_IRQHandler (void);
#endif /* _71x_IT_H */
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,99 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : 71x_lib.h
* Author : MCD Application Team
* Date First Issued : 05/16/2003
* Description : Global include for all peripherals
********************************************************************************
* 30/11/2004 : V2.0
* 14/07/2004 : V1.3
* 01/01/2004 : V1.2
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __71x_LIB_H
#define __71x_LIB_H
#include "71x_map.h"
#include "71x_conf.h"
#ifdef _ADC12
#include "adc12.h"
#endif
#ifdef _APB
#include "apb.h"
#endif
#ifdef _BSPI
#include "bspi.h"
#endif
#ifdef _CAN
#include "can.h"
#endif
#ifdef _EIC
#include "eic.h"
#endif
#ifdef _EMI
#include "emi.h"
#endif
#ifdef _FLASH
#include "flash.h"
#endif
#ifdef _GPIO
#include "gpio.h"
#endif
#ifdef _I2C
#include "i2c.h"
#endif
#ifdef _PCU
#include "pcu.h"
#endif
#ifdef _RCCU
#include "rccu.h"
#endif
#ifdef _RTC
#include "rtc.h"
#endif
#ifdef _TIM
#include "tim.h"
#endif
#ifdef _UART
#include "uart.h"
#endif
#ifdef _USB
#endif
#ifdef _WDG
#include "wdg.h"
#endif
#ifdef _XTI
#include "xti.h"
#endif
#ifdef DEBUG
void debug(void);
#endif
#endif /* __71x_LIB_H */
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,610 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : 71x_map.h
* Author : MCD Application Team
* Date First Issued : 05/16/2003
* Description : Peripherals memory mapping and registers structures
********************************************************************************
* History:
* 30/11/2004 : V2.0
* 14/07/2004 : V1.3
* 01/01/2004 : V1.2
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __71x_map_H
#define __71x_map_H
#ifndef EXT
#define EXT extern
#endif
#include "71x_conf.h"
#include "71x_type.h"
/* IP registers structures */
typedef volatile struct
{
vu16 DATA0;
vu16 EMPTY1[3];
vu16 DATA1;
vu16 EMPTY2[3];
vu16 DATA2;
vu16 EMPTY3[3];
vu16 DATA3;
vu16 EMPTY4[3];
vu16 CSR;
vu16 EMPTY5[7];
vu16 CPR;
} ADC12_TypeDef;
typedef volatile struct
{
vu32 CKDIS;
vu32 SWRES;
} APB_TypeDef;
typedef volatile struct
{
vu16 RXR;
vu16 EMPTY1;
vu16 TXR;
vu16 EMPTY2;
vu16 CSR1;
vu16 EMPTY3;
vu16 CSR2;
vu16 EMPTY4;
vu16 CLK;
} BSPI_TypeDef;
typedef volatile struct
{
vu16 CRR;
vu16 EMPTY1;
vu16 CMR;
vu16 EMPTY2;
vu16 M1R;
vu16 EMPTY3;
vu16 M2R;
vu16 EMPTY4;
vu16 A1R;
vu16 EMPTY5;
vu16 A2R;
vu16 EMPTY6;
vu16 MCR;
vu16 EMPTY7;
vu16 DA1R;
vu16 EMPTY8;
vu16 DA2R;
vu16 EMPTY9;
vu16 DB1R;
vu16 EMPTY10;
vu16 DB2R;
vu16 EMPTY11[27];
} CAN_MsgObj_TypeDef;
typedef volatile struct
{
vu16 CR;
vu16 EMPTY1;
vu16 SR;
vu16 EMPTY2;
vu16 ERR;
vu16 EMPTY3;
vu16 BTR;
vu16 EMPTY4;
vu16 IDR;
vu16 EMPTY5;
vu16 TESTR;
vu16 EMPTY6;
vu16 BRPR;
vu16 EMPTY7[3];
CAN_MsgObj_TypeDef sMsgObj[2];
vu16 EMPTY8[16];
vu16 TR1R;
vu16 EMPTY9;
vu16 TR2R;
vu16 EMPTY10[13];
vu16 ND1R;
vu16 EMPTY11;
vu16 ND2R;
vu16 EMPTY12[13];
vu16 IP1R;
vu16 EMPTY13;
vu16 IP2R;
vu16 EMPTY14[13];
vu16 MV1R;
vu16 EMPTY15;
vu16 MV2R;
vu16 EMPTY16;
} CAN_TypeDef;
typedef volatile struct
{
vu32 ICR;
vu32 CICR;
vu32 CIPR;
vu32 EMPTY1[3];
vu32 IVR;
vu32 FIR;
vu32 IER;
vu32 EMPTY2[7];
vu32 IPR;
vu32 EMPTY3[7];
vu32 SIR[32];
} EIC_TypeDef;
typedef volatile struct
{
vu16 BCON0;
vu16 EMPTY1;
vu16 BCON1;
vu16 EMPTY2;
vu16 BCON2;
vu16 EMPTY3;
vu16 BCON3;
vu16 EMPTY4;
} EMI_TypeDef;
typedef volatile struct
{
vu32 CR0;
vu32 CR1;
vu32 DR0;
vu32 DR1;
vu32 AR;
vu32 ER;
} FLASHR_TypeDef;
typedef volatile struct
{
vu32 NVWPAR;
vu32 EMPTY;
vu32 NVAPR0;
vu32 NVAPR1;
} FLASHPR_TypeDef;
typedef volatile struct
{
vu16 PC0;
vu16 EMPTY1;
vu16 PC1;
vu16 EMPTY2;
vu16 PC2;
vu16 EMPTY3;
vu16 PD;
vu16 EMPTY4;
} GPIO_TypeDef;
typedef volatile struct
{
vu8 CR;
vu8 EMPTY1[3];
vu8 SR1;
vu8 EMPTY2[3];
vu8 SR2;
vu8 EMPTY3[3];
vu8 CCR;
vu8 EMPTY4[3];
vu8 OAR1;
vu8 EMPTY5[3];
vu8 OAR2;
vu8 EMPTY6[3];
vu8 DR;
vu8 EMPTY7[3];
vu8 ECCR;
} I2C_TypeDef;
typedef volatile struct
{
vu32 CCR;
vu32 EMPTY1;
vu32 CFR;
vu32 EMPTY2[3];
vu32 PLL1CR;
vu32 PER;
vu32 SMR;
} RCCU_TypeDef;
typedef volatile struct
{
vu16 MDIVR;
vu16 EMPTY1;
vu16 PDIVR;
vu16 EMPTY2;
vu16 RSTR;
vu16 EMPTY3;
vu16 PLL2CR;
vu16 EMPTY4;
vu16 BOOTCR;
vu16 EMPTY5;
vu16 PWRCR;
} PCU_TypeDef;
typedef volatile struct
{
vu16 CRH;
vu16 EMPTY1;
vu16 CRL;
vu16 EMPTY2;
vu16 PRLH;
vu16 EMPTY3;
vu16 PRLL;
vu16 EMPTY4;
vu16 DIVH;
vu16 EMPTY5;
vu16 DIVL;
vu16 EMPTY6;
vu16 CNTH;
vu16 EMPTY7;
vu16 CNTL;
vu16 EMPTY8;
vu16 ALRH;
vu16 EMPTY9;
vu16 ALRL;
} RTC_TypeDef;
typedef volatile struct
{
vu16 ICAR;
vu16 EMPTY1;
vu16 ICBR;
vu16 EMPTY2;
vu16 OCAR;
vu16 EMPTY3;
vu16 OCBR;
vu16 EMPTY4;
vu16 CNTR;
vu16 EMPTY5;
vu16 CR1;
vu16 EMPTY6;
vu16 CR2;
vu16 EMPTY7;
vu16 SR;
} TIM_TypeDef;
typedef volatile struct
{
vu16 BR;
vu16 EMPTY1;
vu16 TxBUFR;
vu16 EMPTY2;
vu16 RxBUFR;
vu16 EMPTY3;
vu16 CR;
vu16 EMPTY4;
vu16 IER;
vu16 EMPTY5;
vu16 SR;
vu16 EMPTY6;
vu16 GTR;
vu16 EMPTY7;
vu16 TOR;
vu16 EMPTY8;
vu16 TxRSTR;
vu16 EMPTY9;
vu16 RxRSTR;
} UART_TypeDef;
typedef volatile struct
{
vu32 EP0R;
vu32 EP1R;
vu32 EP2R;
vu32 EP3R;
vu32 EP4R;
vu32 EP5R;
vu32 EP6R;
vu32 EP7R;
vu32 EP8R;
vu32 EP9R;
vu32 EP10R;
vu32 EP11R;
vu32 EP12R;
vu32 EP13R;
vu32 EP14R;
vu32 EP15R;
vu32 CNTR;
vu32 ISTR;
vu32 FNR;
vu32 DADDR;
vu32 BTABLE;
} USB_TypeDef;
typedef volatile struct
{
vu16 CR;
vu16 EMPTY1;
vu16 PR;
vu16 EMPTY2;
vu16 VR;
vu16 EMPTY3;
vu16 CNT;
vu16 EMPTY4;
vu16 SR;
vu16 EMPTY5;
vu16 MR;
vu16 EMPTY6;
vu16 KR;
} WDG_TypeDef;
typedef volatile struct
{
vu8 SR;
vu8 EMPTY1[7];
vu8 CTRL;
vu8 EMPTY2[3];
vu8 MRH;
vu8 EMPTY3[3];
vu8 MRL;
vu8 EMPTY4[3];
vu8 TRH;
vu8 EMPTY5[3];
vu8 TRL;
vu8 EMPTY6[3];
vu8 PRH;
vu8 EMPTY7[3];
vu8 PRL;
} XTI_TypeDef;
/* IRQ vectors */
typedef volatile struct
{
vu32 T0TIMI_IRQHandler;
vu32 FLASH_IRQHandler;
vu32 RCCU_IRQHandler;
vu32 RTC_IRQHandler;
vu32 WDG_IRQHandler;
vu32 XTI_IRQHandler;
vu32 USBHP_IRQHandler;
vu32 I2C0ITERR_IRQHandler;
vu32 I2C1ITERR_IRQHandler;
vu32 UART0_IRQHandler;
vu32 UART1_IRQHandler;
vu32 UART2_IRQHandler;
vu32 UART3_IRQHandler;
vu32 BSPI0_IRQHandler;
vu32 BSPI1_IRQHandler;
vu32 I2C0_IRQHandler;
vu32 I2C1_IRQHandler;
vu32 CAN_IRQHandler;
vu32 ADC12_IRQHandler;
vu32 T1TIMI_IRQHandler;
vu32 T2TIMI_IRQHandler;
vu32 T3TIMI_IRQHandler;
vu32 EMPTY1[3];
vu32 HDLC_IRQHandler;
vu32 USBLP_IRQHandler;
vu32 EMPTY2[2];
vu32 T0TOI_IRQHandler;
vu32 T0OC1_IRQHandler;
vu32 T0OC2_IRQHandler;
} IRQVectors_TypeDef;
/*===================================================================*/
/* Memory mapping */
#define RAM_BASE 0x20000000
#define FLASHR_BASE 0x40100000
#define FLASHPR_BASE 0x4010DFB0
#define EXTMEM_BASE 0x60000000
#define RCCU_BASE 0xA0000000
#define PCU_BASE 0xA0000040
#define APB1_BASE 0xC0000000
#define APB2_BASE 0xE0000000
#define EIC_BASE 0xFFFFF800
#define I2C0_BASE (APB1_BASE + 0x1000)
#define I2C1_BASE (APB1_BASE + 0x2000)
#define UART0_BASE (APB1_BASE + 0x4000)
#define UART1_BASE (APB1_BASE + 0x5000)
#define UART2_BASE (APB1_BASE + 0x6000)
#define UART3_BASE (APB1_BASE + 0x7000)
#define CAN_BASE (APB1_BASE + 0x9000)
#define BSPI0_BASE (APB1_BASE + 0xA000)
#define BSPI1_BASE (APB1_BASE + 0xB000)
#define USB_BASE (APB1_BASE + 0x8800)
#define XTI_BASE (APB2_BASE + 0x101C)
#define GPIO0_BASE (APB2_BASE + 0x3000)
#define GPIO1_BASE (APB2_BASE + 0x4000)
#define GPIO2_BASE (APB2_BASE + 0x5000)
#define ADC12_BASE (APB2_BASE + 0x7000)
#define TIM0_BASE (APB2_BASE + 0x9000)
#define TIM1_BASE (APB2_BASE + 0xA000)
#define TIM2_BASE (APB2_BASE + 0xB000)
#define TIM3_BASE (APB2_BASE + 0xC000)
#define RTC_BASE (APB2_BASE + 0xD000)
#define WDG_BASE (APB2_BASE + 0xE000)
#define EMI_BASE (EXTMEM_BASE + 0x0C000000)
/*===================================================================*/
/* IP data access */
#ifndef DEBUG
#define ADC12 ((ADC12_TypeDef *)ADC12_BASE)
#define APB1 ((APB_TypeDef *)APB1_BASE)
#define APB2 ((APB_TypeDef *)APB2_BASE+0x10)
#define BSPI0 ((BSPI_TypeDef *)BSPI0_BASE)
#define BSPI1 ((BSPI_TypeDef *)BSPI1_BASE)
#define CAN ((CAN_TypeDef *)CAN_BASE)
#define EIC ((EIC_TypeDef *)EIC_BASE)
#define EMI ((EMI_TypeDef *)EMI_BASE)
#define FLASHR ((FLASHR_TypeDef *)FLASHR_BASE)
#define FLASHPR ((FLASHPR_TypeDef *)FLASHPR_BASE)
#define GPIO0 ((GPIO_TypeDef *)GPIO0_BASE)
#define GPIO1 ((GPIO_TypeDef *)GPIO1_BASE)
#define GPIO2 ((GPIO_TypeDef *)GPIO2_BASE)
#define I2C0 ((I2C_TypeDef *)I2C0_BASE)
#define I2C1 ((I2C_TypeDef *)I2C1_BASE)
#define PCU ((PCU_TypeDef *)PCU_BASE)
#define RCCU ((RCCU_TypeDef *)RCCU_BASE)
#define RTC ((RTC_TypeDef *)RTC_BASE)
#define TIM0 ((TIM_TypeDef *)TIM0_BASE)
#define TIM1 ((TIM_TypeDef *)TIM1_BASE)
#define TIM2 ((TIM_TypeDef *)TIM2_BASE)
#define TIM3 ((TIM_TypeDef *)TIM3_BASE)
#define UART0 ((UART_TypeDef *)UART0_BASE)
#define UART1 ((UART_TypeDef *)UART1_BASE)
#define UART2 ((UART_TypeDef *)UART2_BASE)
#define UART3 ((UART_TypeDef *)UART3_BASE)
#define USB ((USB_TypeDef *)USB_BASE)
#define WDG ((WDG_TypeDef *)WDG_BASE)
#define XTI ((XTI_TypeDef *)XTI_BASE)
#define IRQVectors ((IRQVectors_TypeDef *)&T0TIMI_Addr)
#else /* DEBUG */
#ifdef _ADC12
EXT ADC12_TypeDef *ADC12;
#endif
#ifdef _APB
#ifdef _APB1
EXT APB_TypeDef *APB1;
#endif
#ifdef _APB2
EXT APB_TypeDef *APB2;
#endif
#endif
#ifdef _BSPI
#ifdef _BSPI0
EXT BSPI_TypeDef *BSPI0;
#endif
#ifdef _BSPI1
EXT BSPI_TypeDef *BSPI1;
#endif
#endif
#ifdef _CAN
EXT CAN_TypeDef *CAN;
#endif
#ifdef _EIC
EXT EIC_TypeDef *EIC;
#endif
#ifdef _EMI
EXT EMI_TypeDef *EMI;
#endif
#ifdef _FLASH
EXT FLASHR_TypeDef *FLASHR;
EXT FLASHPR_TypeDef *FLASHPR;
#endif
#ifdef _GPIO
#ifdef _GPIO0
EXT GPIO_TypeDef *GPIO0;
#endif
#ifdef _GPIO1
EXT GPIO_TypeDef *GPIO1;
#endif
#ifdef _GPIO2
EXT GPIO_TypeDef *GPIO2;
#endif
#endif
#ifdef _I2C
#ifdef _I2C0
EXT I2C_TypeDef *I2C0;
#endif
#ifdef _I2C1
EXT I2C_TypeDef *I2C1;
#endif
#endif
#ifdef _PCU
EXT PCU_TypeDef *PCU;
#endif
#ifdef _RCCU
EXT RCCU_TypeDef *RCCU;
#endif
#ifdef _RTC
EXT RTC_TypeDef *RTC;
#endif
#ifdef _TIM
#ifdef _TIM0
EXT TIM_TypeDef *TIM0;
#endif
#ifdef _TIM1
EXT TIM_TypeDef *TIM1;
#endif
#ifdef _TIM2
EXT TIM_TypeDef *TIM2;
#endif
#ifdef _TIM3
EXT TIM_TypeDef *TIM3;
#endif
#endif
#ifdef _UART
#ifdef _UART0
EXT UART_TypeDef *UART0;
#endif
#ifdef _UART1
EXT UART_TypeDef *UART1;
#endif
#ifdef _UART2
EXT UART_TypeDef *UART2;
#endif
#ifdef _UART3
EXT UART_TypeDef *UART3;
#endif
#endif
#ifdef _USB
EXT USB_TypeDef *USB;
#endif
#ifdef _WDG
EXT WDG_TypeDef *WDG;
#endif
#ifdef _XTI
EXT XTI_TypeDef *XTI;
#endif
#ifdef _IRQVectors
EXT IRQVectors_TypeDef *IRQVectors;
#endif
#endif /* DEBUG */
#endif /* __71x_map_H */
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,50 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : 71x_type.h
* Author : MCD Application Team
* Date First Issued : 05/16/2003
* Description : Common data types
********************************************************************************
* History:
* 30/11/2004 : V2.0
* 14/07/2004 : V1.3
* 01/01/2004 : V1.2
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef _71x_type_H
#define _71x_type_H
typedef unsigned long u32;
typedef unsigned short u16;
typedef unsigned char u8;
typedef signed long s32;
typedef signed short s16;
typedef signed char s8;
typedef volatile unsigned long vu32;
typedef volatile unsigned short vu16;
typedef volatile unsigned char vu8;
typedef volatile signed long vs32;
typedef volatile signed short vs16;
typedef volatile signed char vs8;
/*===================================================================*/
typedef enum { FALSE = 0, TRUE = !FALSE } bool;
/*===================================================================*/
typedef enum { RESET = 0, SET = !RESET } FlagStatus;
/*===================================================================*/
typedef enum { DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
/*===================================================================*/
typedef enum { INDIRECT = 0, DIRECT = !INDIRECT} RegisterAccess;
/*===================================================================*/
#endif /* _71x_type_H */
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,199 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : eic.h
* Author : MCD Application Team
* Date First Issued : 25/06/2003
* Description : This file contains all the functions prototypes for the
* EIC software library.
********************************************************************************
* History:
* 30/11/2004 : V2.0
* 14/07/2004 : V1.3
* 01/01/2004 : V1.2
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __eic_H
#define __eic_H
#include "71x_map.h"
typedef enum
{
T0TIMI_IRQChannel = 0,
FLASH_IRQChannel = 1,
RCCU_IRQChannel = 2,
RTC_IRQChannel = 3,
WDG_IRQChannel = 4,
XTI_IRQChannel = 5,
USBHP_IRQChannel = 6,
I2C0ITERR_IRQChannel = 7,
I2C1ITERR_IRQChannel = 8,
UART0_IRQChannel = 9,
UART1_IRQChannel = 10,
UART2_IRQChannel = 11,
UART3_IRQChannel = 12,
SPI0_IRQChannel = 13,
SPI1_IRQChannel = 14,
I2C0_IRQChannel = 15,
I2C1_IRQChannel = 16,
CAN_IRQChannel = 17,
ADC_IRQChannel = 18,
T1TIMI_IRQChannel = 19,
T2TIMI_IRQChannel = 20,
T3TIMI_IRQChannel = 21,
HDLC_IRQChannel = 25,
USBLP_IRQChannel = 26,
T0TOI_IRQChannel = 29,
T0OC1_IRQChannel = 30,
T0OC2_IRQChannel = 31
} IRQChannel_TypeDef;
typedef enum
{
T0TIMI_FIQChannel = 0x00000001,
WDG_FIQChannel = 0x00000002,
WDGT0TIMI_FIQChannels = 0x00000003
} FIQChannel_TypeDef;
/*******************************************************************************
* Function Name : EIC_Init
* Description : Initialise the EIC using the load PC instruction
* (PC = PC +offset)
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void EIC_Init(void);
/*******************************************************************************
* Function Name : EIC_IRQConfig
* Description : Enable or Disable IRQ interrupts
* Input 1 : New status : can be ENABLE or DISABLE
* Output : None
* Return : None
*******************************************************************************/
inline void EIC_IRQConfig(FunctionalState NewState)
{
if (NewState==ENABLE) EIC->ICR |= 0x0001; else EIC->ICR &= ~0x0001;
}
/*******************************************************************************
* Function Name : EIC_FIQConfig
* Description : Enable or Disable FIQ interrupts
* Input 1 : New status : can be ENABLE or DISABLE
* Output : None
* Return : None
*******************************************************************************/
inline void EIC_FIQConfig(FunctionalState NewState)
{
if (NewState==ENABLE) EIC->ICR |= 0x0002; else EIC->ICR &= ~0x0002;
}
/*******************************************************************************
* Function Name : EIC_IRQChannelConfig
* Description : Configure the IRQ Channel
* Input 1 : IRQ channel name
* Input 2 : Channel New status : can be ENABLE or DISABLE
* Output : None
* Return : None
*******************************************************************************/
inline void EIC_IRQChannelConfig(IRQChannel_TypeDef IRQChannel, FunctionalState NewState)
{
if (NewState==ENABLE) EIC->IER |= 0x0001 << IRQChannel;
else EIC->IER &= ~(0x0001 << IRQChannel);
}
/*******************************************************************************
* Function Name : EIC_FIQChannelConfig
* Description : Configure the FIQ Channel
* Input 1 : FIQ channel name
* Input 2 : Channel New status : can be ENABLE or DISABLE
* Output : None
* Return : None
*******************************************************************************/
inline void EIC_FIQChannelConfig(FIQChannel_TypeDef FIQChannel,
FunctionalState NewState)
{
if (NewState==ENABLE) EIC->FIR |= FIQChannel;
else EIC->FIR &= ~FIQChannel;
}
/*******************************************************************************
* Function Name : EIC_IRQChannelPriorityConfig
* Description : Configure the selected IRQ channel priority
* Input 1 : IRQ channel name
* Input 2 : IRQ channel priority
* Output : None
* Return : None
*******************************************************************************/
inline void EIC_IRQChannelPriorityConfig(IRQChannel_TypeDef IRQChannel, u8 Priority)
{
EIC->SIR[IRQChannel] = (EIC->SIR[IRQChannel]&0xFFFF0000) | (u16)Priority & 0x000F;
}
/*******************************************************************************
* Function Name : EIC_CurrentPriorityLevelConfig
* Description : Change the current priority level of the srved IRQ routine
* Input 1 : New priority
* Output : None
* Return : None
*******************************************************************************/
void EIC_CurrentPriorityLevelConfig(u8 NewPriorityLevel);
/*******************************************************************************
* Function Name : EIC_CurrentPriorityLevelValue
* Description : Return the current priority level of the current served IRQ
* routine
* Input : None
* Output : None
* Return : The current priority level
*******************************************************************************/
inline u8 EIC_CurrentPriorityLevelValue(void)
{
return EIC->CIPR & 0xF;
}
/*******************************************************************************
* Function Name : EIC_CurrentIRQChannelValue
* Description : Return the current served IRQ channel number
* Input 0 : None
* Output : None
* Return : The current served IRQ channel number
*******************************************************************************/
inline IRQChannel_TypeDef EIC_CurrentIRQChannelValue(void)
{
return (IRQChannel_TypeDef)(EIC->CICR & 0x1F);
}
/*******************************************************************************
* Function Name : EIC_CurrentFIQChannelValue
* Description : Return the current served FIQ channel number
* Input : None
* Output : None
* Return : The current served FIQ channel number
*******************************************************************************/
inline FIQChannel_TypeDef EIC_CurrentFIQChannelValue(void)
{
return (FIQChannel_TypeDef)((EIC->FIR >> 2) & 0x0003);
}
/*******************************************************************************
* Function Name : EIC_FIPendingBitClear
* Description : Clear the FIQ pending bit
* Input 1 : FIQ channel
* Output : None
* Return : None
*******************************************************************************/
inline void EIC_FIQPendingBitClear(FIQChannel_TypeDef FIQChannel)
{
EIC->FIR = (EIC->FIR & 0x0003) | (FIQChannel << 2);
}
#endif /* __eic_H */
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,126 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : gpio.h
* Author : MCD Application Team
* Date First Issued : 08/06/2003
* Description : This file contains all the functions prototypes for the
* GPIO software library.
********************************************************************************
* History:
* 30/11/2004 : V2.0
* 14/07/2004 : V1.3
* 01/01/2004 : V1.2
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __gpio_H
#define __gpio_H
#include "71x_map.h"
typedef enum
{
GPIO_HI_AIN_TRI,
GPIO_IN_TRI_TTL,
GPIO_IN_TRI_CMOS,
GPIO_IPUPD_WP,
GPIO_OUT_OD,
GPIO_OUT_PP,
GPIO_AF_OD,
GPIO_AF_PP
} GpioPinMode_TypeDef;
#define GPIO_LSB 0x00
#define GPIO_MSB 0x08
/*******************************************************************************
* Function Name : GPIO_Config
* Description : Configure the GPIO port pins
* Input 1 : GPIOx (x can be 0,1 or 2) the desired port
* Input 2 : Port_Pins : pins placements
* Input 3 : Pins Mode
* Output : None
* Return : None
*******************************************************************************/
void GPIO_Config (GPIO_TypeDef *GPIOx, u16 Port_Pins, GpioPinMode_TypeDef GPIO_Mode);
/*******************************************************************************
* Function Name : GPIO_BitRead
* Description : Read the desired port pin value
* Input 1 : Selected GPIO port
* Input 2 : Pin number
* Output : None
* Return : The selected pin value
*******************************************************************************/
inline u8 GPIO_BitRead(GPIO_TypeDef *GPIOx, u8 Port_Pin)
{
return (GPIOx->PD >> Port_Pin) & 0x0001;
}
/*******************************************************************************
* Function Name : GPIO_ByteRead
* Description : Read the desired port Byte value
* Input 1 : Selected GPIO port
* Input 2 : GPIO_MSB or GPIO_LSB
* Output : None
* Return : The GPIO_MSB or GPIO_LSB of the selected PD register
*******************************************************************************/
inline u8 GPIO_ByteRead(GPIO_TypeDef *GPIOx, u8 Port_Byte)
{
return (u8)(GPIOx->PD >> Port_Byte);
}
/*******************************************************************************
* Function Name : GPIO_WordRead
* Description : Read the desired port word value
* Input 1 : Selected GPIO port
* Output : None
* Return : The selected PD register value
*******************************************************************************/
inline u16 GPIO_WordRead(GPIO_TypeDef *GPIOx)
{
return GPIOx->PD;
}
/*******************************************************************************
* Function Name : GPIO_BitWrite
* Description : Set or reset the selected port pin
* Input 1 : Selected GPIO port
* Input 2 : Pin number
* Input 3 : bit value
* Output : None
* Return : None
*******************************************************************************/
void GPIO_BitWrite(GPIO_TypeDef *GPIOx, u8 Port_Pin, u8 Port_Val);
/*******************************************************************************
* Function Name : GPIO_ByteWrite
* Description : Write byte value to the selected PD register
* Input 1 : Selected GPIO port
* Input 2 : GPIO_MSB or GPIO_LSB
* Input 3 : Byte value
* Output : None
* Return : None
*******************************************************************************/
void GPIO_ByteWrite(GPIO_TypeDef *GPIOx, u8 Port_Byte, u8 Port_Val);
/*******************************************************************************
* Function Name : GPIO_WordWrite
* Description : Write word value to the selected PD register
* Input 1 : Selected GPIO port
* Input 2 : Value
* Output : None
* Return : None
*******************************************************************************/
inline void GPIO_WordWrite(GPIO_TypeDef *GPIOx, u16 Port_Val)
{
GPIOx->PD = Port_Val;
}
#endif /* __gpio_H */
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,193 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : pcu.h
* Author : MCD Application Team
* Date First Issued : 30/05/2003
* Description : This file contains all the functions prototypes for the
* PCU software library.
********************************************************************************
* History:
* 30/11/2004 : V2.0
* 14/07/2004 : V1.3
* 01/01/2004 : V1.2
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __PCU_H
#define __PCU_H
#include "71x_map.h"
typedef enum
{
PCU_WREN = 0x8000,
PCU_VROK = 0x1000
} PCU_Flags;
typedef enum
{
PCU_STABLE,
PCU_UNSTABLE
} PCU_VR_Status;
typedef enum
{
PCU_MVR = 0x0008,
PCU_LPR = 0x0020
} PCU_VR;
typedef enum
{
WFI_CLOCK2_16,
WFI_EXTERNAL
} WFI_CLOCKS;
typedef enum
{
PCU_SLOW,
PCU_STOP,
PCU_STANDBY
} LPM_MODES;
// VR_OK : Voltage Regulator OK
#define PCU_VROK_Mask 0x1000
// Main Voltage Regulator
#define PCU_MVR_Mask 0x0008
// Low Power Voltage Regulator
#define PCU_LPR_Mask 0x0020
// PCU register Write Enable Bit
#define PCU_WREN_Mask 0x8000
// Low Voltage Detector
#define PCU_LVD_Mask 0x0100
// Power Down Flag
#define PCU_PWRDWN_Mask 0x0040
// WFI Mode Clock Selection Bit
#define PCU_WFI_CKSEL_Mask 0x00000002
// Halt Mode Enable Bit
#define PCU_EN_HALT_Mask 0x00000800
// Halt Mode Flag
#define PCU_HALT_Mask 0x0002
// Stop Mode Enable Bit
#define PCU_STOP_EN_Mask 0x00000400
// Low Power Regulator in Wait For interrupt Mode
#define PCU_LPRWFI_Mask 0x0020
// Low Power Mode in Wait For interrupt Mode
#define PCU_LPOWFI_Mask 0x00000001
// Software Reset Enable
#define PCU_SRESEN_Mask 0x00000001
/*******************************************************************************
* Function Name : PCU_MVRStatus
* Description : This routine is used to check the Main Voltage Regulator
* : NewState.
* Input : None
* Return : STABLE, UNSTABLE
*******************************************************************************/
inline PCU_VR_Status PCU_MVRStatus ( void )
{
return (PCU->PWRCR & PCU_VROK_Mask) == 0x00 ? PCU_UNSTABLE : PCU_STABLE;
}
/*******************************************************************************
* Function Name : PCU_FlagStatus
* Description : This routine is used to return the PCU register flag
* Input 1 : The flag to get
* Return : RESET, SET
*******************************************************************************/
inline FlagStatus PCU_FlagStatus ( PCU_Flags Xflag )
{
return ( PCU->PWRCR & Xflag ) == 0x00 ? RESET : SET;
}
/*******************************************************************************
* Function Name : PCU_VRConfig
* Description : This routine is used to configure PCU voltage regultors
* Input 1 : MVR : Main voltage Regulator
LPR : Low Power Regulator
* Input 2 : ENABLE : Enable the Voltage Regulator
DISABLE: Disable ( ByPass ) the VR
* Return : None
*******************************************************************************/
void PCU_VRConfig ( PCU_VR xVR, FunctionalState NewState );
/*******************************************************************************
* Function Name : PCU_VRStatus
* Description : This routine is used to get the PCU voltage regultors status
* Input : MVR : Main voltage Regulator
LPR : Low Power Regulator
* Return : ENABLE : Enable the Voltage Regulator
DISABLE: Disable ( ByPass ) the VR
*******************************************************************************/
inline FunctionalState PCU_VRStatus ( PCU_VR xVR )
{
return ( PCU->PWRCR & xVR ) == 0 ? ENABLE : DISABLE;
}
/*******************************************************************************
* Function Name : PCU_LVDDisable
* Description : This routine is used to disable the Low Voltage Detector.
* Input : None
* Return : None
*******************************************************************************/
inline void PCU_LVDDisable ( void )
{
PCU->PWRCR |= PCU_WREN_Mask; // Unlock Power Control Register
PCU->PWRCR |= PCU_LVD_Mask; // Set the LVD DIS Flag
}
/*******************************************************************************
* Function Name : PCU_LVDStatus
* Description : This routine is used to get the LVD NewState.
* Input : None
* Return : ENABLE, DISABLE
*******************************************************************************/
inline FunctionalState PCU_LVDStatus ( void )
{
return ( PCU->PWRCR & PCU_LVD_Mask ) == 0 ? ENABLE : DISABLE;
}
/*******************************************************************************
* Function Name : PCU_WFIEnter
* Description : This routine is used to force the Device to enter in WFI mode
* Input 1 : CLOCK2_16 : Clock2_16 as system clock for WFI mode
* EXTERNAL : external clock as system clock for WFI mode
* Input 2 : ENABLE : Enable Low Power Regulator during Wait For Interrupt Mode
* DISABLE: Disable Low Power Regulator during Wait For Interrupt Mode
* Input 3 : ENABLE : Enable Low Power Mode during Wait For Interrupt Mode
* DISABLE: Disable Low Power Mode during Wait For Interrupt Mode
* Return : None
*******************************************************************************/
void PCU_WFIEnter ( WFI_CLOCKS Xclock, FunctionalState Xlpr, FunctionalState Xlpm );
/*******************************************************************************
* Function Name : PCU_LPMEnter
* Description : This routine is used to force the Device to enter low
* power mode
* Input : SLOW : Slow Mode
STOP : Stop Mode
HALT : Halt Mode
* Return : None
*******************************************************************************/
void PCU_LPMEnter ( LPM_MODES Xmode);
#endif // __PCU_H
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,319 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : rccu.h
* Author : MCD Application Team
* Date First Issued : 28/07/2003
* Description : This file contains all the functions prototypes for the
* RCCU software library.
********************************************************************************
* History:
* 30/11/2004 : V2.0
* 14/07/2004 : V1.3
* 01/01/2004 : V1.2
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __RCCU_H
#define __RCCU_H
#include "71x_map.h"
typedef enum {
RCCU_DEFAULT=0x00,
RCCU_RCLK_2 =0x01,
RCCU_RCLK_4 =0x02,
RCCU_RCLK_8 =0x03
} RCCU_Clock_Div;
typedef enum {
RCCU_PLL1_Output,
RCCU_CLOCK2_16,
RCCU_CLOCK2,
RCCU_RTC_CLOCK
} RCCU_RCLK_Clocks;
typedef enum {
RCCU_PLL1_Mul_12=0x01,
RCCU_PLL1_Mul_16=0x03,
RCCU_PLL1_Mul_20=0x00,
RCCU_PLL1_Mul_24=0x02
} RCCU_PLL1_Mul;
typedef enum {
RCCU_PLL2_Mul_12=0x01,
RCCU_PLL2_Mul_16=0x03,
RCCU_PLL2_Mul_20=0x00,
RCCU_PLL2_Mul_28=0x02
} RCCU_PLL2_Mul;
typedef enum {
RCCU_Div_1=0x00,
RCCU_Div_2=0x01,
RCCU_Div_3=0x02,
RCCU_Div_4=0x03,
RCCU_Div_5=0x04,
RCCU_Div_6=0x05,
RCCU_Div_7=0x06
} RCCU_PLL_Div;
typedef enum {
RCCU_PLL2_Output = 0x01,
RCCU_USBCK = 0x00
} RCCU_USB_Clocks;
typedef enum {
RCCU_CLK2,
RCCU_RCLK,
RCCU_MCLK,
RCCU_PCLK,
RCCU_FCLK
} RCCU_Clocks;
typedef enum {
RCCU_PLL1_LOCK_IT = 0x0080,
RCCU_CKAF_IT = 0x0100,
RCCU_CK2_16_IT = 0x0200,
RCCU_STOP_IT = 0x0400
} RCCU_Interrupts;
typedef enum {
RCCU_PLL1_LOCK = 0x0002,
RCCU_CKAF_ST = 0x0004,
RCCU_PLL1_LOCK_I = 0x0800,
RCCU_CKAF_I = 0x1000,
RCCU_CK2_16_I = 0x2000,
RCCU_STOP_I = 0x4000
} RCCU_Flags;
typedef enum {
RCCU_ExternalReset = 0x00000000,
RCCU_SoftwareReset = 0x00000020,
RCCU_WDGReset = 0x00000040,
RCCU_RTCAlarmReset = 0x00000080,
RCCU_LVDReset = 0x00000200,
RCCU_WKPReset = 0x00000400
}RCCU_ResetSources;
#define RCCU_Div2_Mask 0x00008000
#define RCCU_Div2_Index 0x0F
#define RCCU_FACT_Mask 0x0003
#define RCCU_FACT1_Mask 0x0003
#define RCCU_FACT2_Mask 0x0300
#define RCCU_FACT2_Index 0x08
#define RCCU_MX_Mask 0x00000030
#define RCCU_MX_Index 0x04
#define RCCU_DX_Mask 0x00000007
#define RCCU_FREEN_Mask 0x00000080
#define RCCU_CSU_CKSEL_Mask 0x00000001
#define RCCU_CK2_16_Mask 0x00000008
#define RCCU_CKAF_SEL_Mask 0x00000004
#define RCCU_LOCK_Mask 0x00000002
#define RCCU_USBEN_Mask 0x0100
#define RCCU_USBEN_Index 0x08
#define RCCU_ResetSources_Mask 0x000006E0
// RTC Oscillator Frequency value = 32 768 Hz
#define RCCU_RTC_Osc 32768
/*******************************************************************************
* Function Name : RCCU_Div2Config
* Description : Enables/Disables the clock division by two
* Input : NewState : ENABLE or DISABLE
* Return : None
*******************************************************************************/
inline void RCCU_Div2Config ( FunctionalState NewState )
{
if (NewState == ENABLE) RCCU->CFR |= RCCU_Div2_Mask;
else RCCU->CFR &= ~RCCU_Div2_Mask;
}
/*******************************************************************************
* Function Name : RCCU_Div2Status
* Description : Gets the Div2 Flag status
* Input : None
* Input : FlagStatus
* Return : None
*******************************************************************************/
inline FlagStatus RCCU_Div2Status ( void )
{
return (RCCU->CFR & RCCU_Div2_Mask) == 0 ? RESET : SET;
}
/*******************************************************************************
* Function Name : RCCU_MCLKConfig
* Description : Selects the division factor for RCLK to obtain the
* MCLK clock for the CPU
* Input : New_Clock : RCCU_DEFAULT, RCCU_RCLK_2, RCCU_RCLK_4, RCCU_RCLK_8
* Return : None
*******************************************************************************/
inline void RCCU_MCLKConfig ( RCCU_Clock_Div New_Clock )
{
PCU->MDIVR = ( PCU->MDIVR & ~RCCU_FACT_Mask ) | New_Clock;
}
/*******************************************************************************
* Function Name : RCCU_FCLKConfig
* Description : Selects the division factor for RCLK to obtain the
* FCLK clock for the APB1 fast peripherals (PCLK1).
* Input : New_Clock : RCCU_DEFAULT, RCCU_RCLK_2,
* RCCU_RCLK_4, RCCU_RCLK_8
* Return : None
*******************************************************************************/
inline void RCCU_FCLKConfig ( RCCU_Clock_Div New_Clock )
{
PCU->PDIVR = ( PCU->PDIVR & ~RCCU_FACT1_Mask ) | New_Clock;
}
/*******************************************************************************
* Function Name : RCCU_PCLKConfig
* Description : Selects the division factor for RCLK to obtain the
* PCLK clock for the APB2 peripherals (PCLK2).
* Input : New_Clock : RCCU_DEFAULT, RCCU_RCLK_2,
* RCCU_RCLK_4, RCCU_RCLK_8
* Return : None
*******************************************************************************/
inline void RCCU_PCLKConfig ( RCCU_Clock_Div New_Clock )
{
PCU->PDIVR =(PCU->PDIVR & ~RCCU_FACT2_Mask)|(New_Clock << RCCU_FACT2_Index);
}
/*******************************************************************************
* Function Name : RCCU_PLL1Config
* Description : Configures the PLL1 div & mul factors.
* Input : New_Mul : RCCU_Mul_12, RCCU_Mul_16, RCCU_Mul_20, RCCU_Mul_28
* : New_Div : RCCU_Div_1, RCCU_Div_2, RCCU_Div_3,
* RCCU_Div_4, RCCU_Div_5, RCCU_Div_6, RCCU_Div_7
* Return : None
*******************************************************************************/
void RCCU_PLL1Config ( RCCU_PLL1_Mul New_Mul, RCCU_PLL_Div New_Div );
/*******************************************************************************
* Function Name : RCCU_PLL2Config
* Description : Configures the PLL2 div & mul factors.
* Input : New_Mul : RCCU_Mul_12, RCCU_Mul_16, RCCU_Mul_20, RCCU_Mul_28
* : New_Div : RCCU_Div_1, RCCU_Div_2, RCCU_Div_3, RCCU_Div_4,
* RCCU_Div_5, RCCU_Div_6, RCCU_Div_7
* Return : None
*******************************************************************************/
void RCCU_PLL2Config ( RCCU_PLL2_Mul New_Mul, RCCU_PLL_Div New_Div );
/*******************************************************************************
* Function Name : RCCU_RCLKSourceConfig
* Description : Selects the RCLK source clock
* Input : New_Clock : RCCU_PLL1_OutPut, RCCU_CLOCK2_16, RCCU_CLOCK2
* Return : None
*******************************************************************************/
void RCCU_RCLKSourceConfig ( RCCU_RCLK_Clocks New_Clock );
/*******************************************************************************
* Function Name : RCCU_RCLKClockSource
* Description : Returns the current RCLK source clock
* Input : None
* Return : RCCU_PLL1_Output, RCCU_CLOCK2_16, RCCU_CLOCK2
*******************************************************************************/
RCCU_RCLK_Clocks RCCU_RCLKClockSource ( void );
/*******************************************************************************
* Function Name : RCCU_USBCLKConfig
* Description : Selects the USB source clock
* Input : New_Clock : RCCU_PLL2_Output, RCCU_USBCK
* Return : None
*******************************************************************************/
inline void RCCU_USBCLKConfig ( RCCU_USB_Clocks New_Clock )
{
PCU->PLL2CR = (PCU->PLL2CR & ~RCCU_USBEN_Mask)|(New_Clock << RCCU_USBEN_Index);
}
/*******************************************************************************
* Function Name : RCCU_USBClockSource
* Description : Gets the USB source clock
* Input : None
* Return : RCCU_USB_Clocks
*******************************************************************************/
RCCU_USB_Clocks RCCU_USBClockSource ( void );
/*******************************************************************************
* Function Name : RCCU_FrequencyValue
* Description : Calculates & Returns any internal RCCU clock freuqency
* passed in parametres
* Input : RCCU_Clocks : RCCU_CLK2, RCCU_RCLK, RCCU_MCLK,
* RCCU_PCLK, RCCU_FCLK
* Return : u32
*******************************************************************************/
u32 RCCU_FrequencyValue ( RCCU_Clocks Internal_Clk );
/*******************************************************************************
* Function Name : RCCU_ITConfig
* Description : Configures the RCCU interrupts
* Input : RCCU interrupts : RCCU_CK2_16_IT, RCCU_CKAF_IT,
* RCCU_PLL1_LOCK_IT
* Return : None
*******************************************************************************/
inline void RCCU_ITConfig ( RCCU_Interrupts RCCU_IT, FunctionalState NewState)
{
if (NewState == ENABLE) RCCU->CCR |= RCCU_IT; else RCCU->CCR &= ~RCCU_IT;
}
/*******************************************************************************
* Function Name : RCCU_FlagStatus
* Description : Checks the RCCU clock flag register status
* Input : RCCU Flags : RCCU_CK2_16, RCCU_CKAF, RCCU_PLL1_LOCK
* Return : FlagStatus : SET or RESET
*******************************************************************************/
inline FlagStatus RCCU_FlagStatus ( RCCU_Flags RCCU_flag )
{
return (RCCU->CFR & RCCU_flag) == 0 ? RESET : SET;
}
/*******************************************************************************
* Function Name : RCCU_FlagClear
* Description : Clears a specified flag in the RCCU registers
* Input : RCCU Flags : RCCU_CK2_16, RCCU_CKAF, RCCU_PLL1_LOCK
* Return : None
*******************************************************************************/
inline void RCCU_FlagClear ( RCCU_Interrupts RCCU_IT )
{
RCCU->CFR |= RCCU_IT;
}
/*******************************************************************************
* Function Name : RCCU_ResetSources
* Description : Return the source of the system reset
* Input : None
* Return : The reset source
*******************************************************************************/
inline RCCU_ResetSources RCCU_ResetSource ()
{
switch(RCCU->CFR & RCCU_ResetSources_Mask)
{
case 0x00000020: return RCCU_SoftwareReset;
case 0x00000040: return RCCU_WDGReset;
case 0x00000080: return RCCU_RTCAlarmReset;
case 0x00000200: return RCCU_LVDReset;
case 0x00000400: return RCCU_WKPReset;
default : return RCCU_ExternalReset;
}
}
#endif // __RCCU_H
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,345 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : tim.h
* Author : MCD Application Team
* Date First Issued : 08/09/2003
* Description : This file contains all the functions prototypes for the
* TIM software library.
********************************************************************************
* History:
* 30/11/2004 : V2.0
* 14/07/2004 : V1.3
* 01/01/2004 : V1.2
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __TIM_H
#define __TIM_H
#include "71x_map.h"
typedef enum { TIM_EXTERNAL,
TIM_INTERNAL
} TIM_Clocks;
typedef enum { TIM_RISING,
TIM_FALLING
} TIM_Clock_Edges;
typedef enum { TIM_CHANNEL_A,
TIM_CHANNEL_B
} TIM_Channels;
typedef enum { TIM_WITH_IT,
TIM_WITHOUT_IT
} TIM_IT_Mode;
typedef enum { TIM_TIMING,
TIM_WAVE
} TIM_OC_Modes;
typedef enum { TIM_HIGH,
TIM_LOW
} TIM_Logic_Levels;
typedef enum { TIM_START,
TIM_STOP,
TIM_CLEAR
} TIM_CounterOperations;
typedef enum { TIM_ICFA = 0x8000,
TIM_OCFA = 0x4000,
TIM_TOF = 0x2000,
TIM_ICFB = 0x1000,
TIM_OCFB = 0x0800
} TIM_Flags;
typedef struct { u16 Pulse;
u16 Period;
} PWMI_parameters;
#define TIM_ECKEN_Mask 0x0001
#define TIM_EXEDG_Mask 0x0002
#define TIM_IEDGA_Mask 0x0004
#define TIM_IEDGB_Mask 0x0008
#define TIM_PWM_Mask 0x0010
#define TIM_OMP_Mask 0x0020
#define TIM_OCAE_Mask 0x0040
#define TIM_OCBE_Mask 0x0080
#define TIM_OLVLA_Mask 0x0100
#define TIM_OLVLB_Mask 0x0200
#define TIM_FOLVA_Mask 0x0400
#define TIM_FOLVB_Mask 0x0800
#define TIM_PWMI_Mask 0x4000
#define TIM_EN_Mask 0x8000
#define TIM_OCBIE_mask 0x0800
#define TIM_ICBIE_Mask 0x1000
#define TIM_TOE_Mask 0x2000
#define TIM_ICAIE_Mask 0x8000
#define TIM_OCAIE_mask 0x4000
#define TIM_ICA_IT 0x8000 // Input Capture Channel A
#define TIM_OCA_IT 0x4000 // Output Compare Channel A
#define TIM_TO_IT 0x2000 // Timer OverFlow
#define TIM_ICB_IT 0x1000 // Input Capture Channel B
#define TIM_OCB_IT 0x0800 // Input Capture Channel A
/*******************************************************************************
* Function Name : TIM_Init
* Description : This routine is used to Initialize the TIM peripheral
* Input : TIM Timer to Initialize
* Return : None
*******************************************************************************/
void TIM_Init( TIM_TypeDef *TIMx );
/*******************************************************************************
* Function Name : TIM_ClockSourceConfig
* Description : This routine is used to configure the TIM clock source
* Input : (1) TIM Timer
* : (2) TIM_Clocks : Specifies the TIM source clock
* - TIM_INTERNAL : The TIM is clocked by the APB2 frequency
* divided by the prescaler value.
* - TIM_EXTERNAL : The TIM is clocked by an external Clock
* Return : None
*******************************************************************************/
inline void TIM_ClockSourceConfig ( TIM_TypeDef *TIMx, TIM_Clocks Xclock )
{
if (Xclock==TIM_EXTERNAL) TIMx->CR1|=TIM_ECKEN_Mask; else TIMx->CR1&=~TIM_ECKEN_Mask;
}
/*******************************************************************************
* Function Name : TIM_ClockSourceValue
* Description : This routine is used to get the TIM clock source
* Input : TIM Timer
* Return : TIM_Clocks : Specifies the TIM source clock
* - TIM_INTERNAL : The TIM is clocked by the APB2 frequency
* divided by the prescaler value.
* - TIM_EXTERNAL : The TIM is clocked by an external Clock
*******************************************************************************/
inline TIM_Clocks TIM_ClockSourceValue ( TIM_TypeDef *TIMx )
{
return ( TIMx->CR1 & TIM_ECKEN_Mask) == 0 ? TIM_INTERNAL : TIM_EXTERNAL;
}
/*******************************************************************************
* Function Name : TIM_PrescalerConfig
* Description : This routine is used to configure the TIM prescaler value
* ( using an internal clock )
* Input : (1) TIM Timer
* : (2) Prescaler ( u8 )
* Return : None
*******************************************************************************/
inline void TIM_PrescalerConfig ( TIM_TypeDef *TIMx, u8 Xprescaler )
{
TIMx->CR2 = ( TIMx->CR2 & 0xFF00 ) | Xprescaler;
}
/*******************************************************************************
* Function Name : TIM_PrescalerValue
* Description : This routine is used to get the TIM prescaler value
* ( when using using an internal clock )
* Input : TIM Timer
* Return : Prescaler ( u8 )
*******************************************************************************/
inline u8 TIM_PrescalerValue ( TIM_TypeDef *TIMx )
{
return TIMx->CR2 & 0x00FF;
}
/*******************************************************************************
* Function Name : TIM_ClockLevelConfig
* Description : This routine is used to configure the TIM clock level
* ( using an external clock )
* Input : TIM Timer
* : TIM_Clock_Edges : Specifies the active adge of the external clock
* - TIM_RISING : The rising edge
* - TIM_FALLING : The falling edge
* Return : None
*******************************************************************************/
inline void TIM_ClockLevelConfig ( TIM_TypeDef *TIMx, TIM_Clock_Edges Xedge )
{
if (Xedge == TIM_RISING) TIMx->CR1 |= TIM_EXEDG_Mask; else TIMx->CR1 &= ~TIM_EXEDG_Mask;
}
/*******************************************************************************
* Function Name : TIM_ClockLevelValue
* Description : This routine is used to get the TIM clock level
* Input : TIM Timer
* Output : TIM_Clock_Edges : Specifies the active adge of the external clock
* - TIM_RISING : The rising edge
* - TIM_FALLING : The falling edge
*******************************************************************************/
inline TIM_Clock_Edges TIM_ClockLevelValue ( TIM_TypeDef *TIMx )
{
return ( TIMx->CR1 & TIM_EXEDG_Mask ) == 0 ? TIM_FALLING : TIM_RISING;
}
/*******************************************************************************
* Function Name : TIM_ICAPModeConfig
* Description : This routine is used to configure the input capture feature
* Input : (1) TIM Timer
* : (2) Input Capture Channel ( Channel_A or Channel_B )
* : (3) Active Edge : Rising edge or Falling edge.
* Output : None
*******************************************************************************/
void TIM_ICAPModeConfig ( TIM_TypeDef *TIMx,
TIM_Channels Xchannel,
TIM_Clock_Edges Xedge );
/*******************************************************************************
* Function Name : TIM_ICAPValue
* Description : This routine is used to get the Input Capture value
* Input : (1) TIM Timer
* : (2) Input Capture Channel ( Channel_A or Channel_B )
* Output : None
*******************************************************************************/
inline u16 TIM_ICAPValue ( TIM_TypeDef *TIMx, TIM_Channels Xchannel )
{
return Xchannel == TIM_CHANNEL_A ? TIMx->ICAR : TIMx->ICBR;
}
/*******************************************************************************
* Function Name : TIM_OCMPModeConfig
* Description : This routine is used to configure the output compare feature
* Input : (1) TIM Timer
* : (2) OCMP Channel ( Channel_A or Channel_B )
* : (3) Pulse Length
* : (4) OC_Mode : output wave, or only timing.
* : (5) Level : Rising edge or Falling edge after the ==
* Output : None
*******************************************************************************/
void TIM_OCMPModeConfig ( TIM_TypeDef *TIMx,
TIM_Channels Xchannel,
u16 XpulseLength,
TIM_OC_Modes Xmode,
TIM_Logic_Levels Xlevel );
/*******************************************************************************
* Function Name : TIM_OPModeConfig
* Description : This routine is used to configure the one pulse mode
* Input : (1) TIM Timer
* : (3) XpulseLength : Length of the pulse
* : (4) Level1 : Level during the pulse
* : (5) Level2 : Level after the pulse
* : (6) Activation Edge : High or Low on ICAP A
* Output : None
*******************************************************************************/
void TIM_OPModeConfig ( TIM_TypeDef *TIMx,
u16 XpulseLength,
TIM_Logic_Levels XLevel1,
TIM_Logic_Levels XLevel2,
TIM_Clock_Edges Xedge );
/*******************************************************************************
* Function Name : TIM_PWMOModeConfig
* Description : This routine is used to configure the PWM in output mode
* Input : (1) TIM Timer
* : (2) DutyCycle : u16
* : (3) Level 1 : During the Duty Cycle
* : (4) Level 2 : During the after the pulse
* : (5) Full period : u16
* Output : None
*******************************************************************************/
void TIM_PWMOModeConfig ( TIM_TypeDef *TIMx,
u16 XDutyCycle,
TIM_Logic_Levels XLevel1,
u16 XFullperiod,
TIM_Logic_Levels XLevel2
);
/*******************************************************************************
* Function Name : TIM_PWMInputConfig
* Description : This routine is used to configure the PWM in input mode
* Input : (1) TIM Timer
* : (2) First Activation Edge
* Output : None
*******************************************************************************/
void TIM_PWMIModeConfig ( TIM_TypeDef *TIMx, TIM_Clock_Edges Xedge );
/*******************************************************************************
* Function Name : TIM_PWMIValue
* Description : This routine is used to get the PWMI values
* Input : (1) TIM Timer
* Output : PWMI_parameters : - u16 Dyty cycle
- u16 Full period
*******************************************************************************/
PWMI_parameters TIM_PWMIValue (TIM_TypeDef *TIMx );
/*******************************************************************************
* Function Name : TIM_CounterConfig
* Description : This routine is used to start/stop and clear the selected
* timer counter
* Input : (1) TIM Timer
* : (2) TIM_CounterOperations
TIM_START Enables or resumes the counter
* TIM_STOP Stops the TIM counter
* TIM_CLEAR Set the TIM counter value to FFFCh
* Output : None
*******************************************************************************/
void TIM_CounterConfig ( TIM_TypeDef *TIMx, TIM_CounterOperations Xoperation );
/*******************************************************************************
* Function Name : TIM_ITConfig
* Description : This routine is used to configure the TIM IT
* Input : (1) TIM Timer
* : (2) TIM interrupt
* : (2) ENABLE / DISABLE
* Output : None
*******************************************************************************/
inline void TIM_ITConfig ( TIM_TypeDef *TIMx, u16 New_IT, FunctionalState NewState )
{
if (NewState == ENABLE) TIMx->CR2 |= New_IT; else TIMx->CR2 &= ~New_IT;
}
/*******************************************************************************
* Function Name : TIM_FlagStatus
* Description : This routine is used to check whether a Flag is Set.
* Input : (1) TIM Timer
* : (2) The TIM FLag
* Output : Flag NewState
*******************************************************************************/
inline FlagStatus TIM_FlagStatus ( TIM_TypeDef *TIMx, TIM_Flags Xflag )
{
return (TIMx->SR & Xflag) == 0 ? RESET : SET;
}
/*******************************************************************************
* Function Name : TIM_FlagClear
* Description : This routine is used to clear Flags.
* Input : (1) TIM Timer
* : (2) The TIM FLag
* Output : None
*******************************************************************************/
inline void TIM_FlagClear ( TIM_TypeDef *TIMx, TIM_Flags Xflag )
{
TIMx->SR &= ~Xflag;
}
/*******************************************************************************
* Function Name : TIM_CounterValue
* Description : This routine returns the timer counter value.
* Input : TIM Timer
* Output : The counter value
*******************************************************************************/
inline u16 TIM_CounterValue(TIM_TypeDef *TIMx)
{
return TIMx->CNTR;
}
#endif // __TIM_H
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,390 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : uart.h
* Author : MCD Application Team
* Date First Issued : 16/05/2003
* Description : This file contains all the functions prototypes for the
* UART software library.
********************************************************************************
* History:
* 30/11/2004 : V2.0
* 14/07/2004 : V1.3
* 01/01/2004 : V1.2
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef _UART_H
#define _UART_H
#include "71x_map.h"
#include "rccu.h"
typedef enum
{
UART_RxFIFO,
UART_TxFIFO
} UARTFIFO_TypeDef;
typedef enum
{
UART_EVEN_PARITY = 0x0000,
UART_ODD_PARITY = 0x0020,
UART_NO_PARITY
} UARTParity_TypeDef;
typedef enum
{
UART_0_5_StopBits = 0x00,
UART_1_StopBits = 0x08,
UART_1_5_StopBits = 0x10,
UART_2_StopBits = 0x18
} UARTStopBits_TypeDef;
typedef enum
{
UARTM_8D = 0x01,
UARTM_7D_P = 0x03,
UARTM_9D = 0x04,
UARTM_8D_W = 0x05,
UARTM_8D_P = 0x07
} UARTMode_TypeDef;
#define DUMMY 0
// UART flags definition
#define UART_TxFull 0x0200
#define UART_RxHalfFull 0x0100
#define UART_TimeOutIdle 0x0080
#define UART_TimeOutNotEmpty 0x0040
#define UART_OverrunError 0x0020
#define UART_FrameError 0x0010
#define UART_ParityError 0x0008
#define UART_TxHalfEmpty 0x0004
#define UART_TxEmpty 0x0002
#define UART_RxBufFull 0x0001
// CR regiter bit definition
#define UART_FIFOEnableBit 10
#define UART_RxEnableBit 8
#define UART_RunBit 7
#define UART_LoopBackBit 6
#define UART_ParityOddBit 5
#define UART_StopBits 3
// Stop bits definition
#define UART_05StopBits 0x00
#define UART_1StopBit (0x01<<3)
#define UART_15StopBits (0x02<<3)
#define UART_2StopBits (0x03<<3)
// Modes definition
#define UART_8BitsData 0x01
#define UART_7BitsData 0x03
#define UART_9BitsData 0x04
#define UART_8BitsDataWakeUp 0x05
#define UART_8BitsDataParity 0x07
/*******************************************************************************
* Function Name : UART_Init
* Description : This function initializes the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Output : None
* Return : None
*******************************************************************************/
void UART_Init(UART_TypeDef *UARTx);
/*******************************************************************************
* Function Name : UART_ModeConfig
* Description : This function configures the mode of the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : The UART mode
* Output : None
* Return : None
*******************************************************************************/
inline void UART_ModeConfig(UART_TypeDef *UARTx, UARTMode_TypeDef UART_Mode)
{
UARTx->CR = (UARTx->CR&0xFFF8)|(u16)UART_Mode;
}
/*******************************************************************************
* Function Name : UART_BaudRateConfig
* Description : This function configures the baud rate of the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : The baudrate value
* Output : None
* Return : None
*******************************************************************************/
void UART_BaudRateConfig(UART_TypeDef *UARTx, u32 BaudRate);
/*******************************************************************************
* Function Name : UART_ParityConfig
* Description : This function configures the data parity of the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : The parity type
* Output : None
* Return : None
*******************************************************************************/
inline void UART_ParityConfig(UART_TypeDef *UARTx, UARTParity_TypeDef Parity)
{
UARTx->CR = (UARTx->CR&0xFFDF)|(u16)Parity;
}
/*******************************************************************************
* Function Name : UART_StopBitsConfig
* Description : This function configures the number of stop bits of the
* selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : The number of stop bits
* Output : None
* Return : None
*******************************************************************************/
inline void UART_StopBitsConfig(UART_TypeDef *UARTx, UARTStopBits_TypeDef StopBits)
{
UARTx->CR = (UARTx->CR&0xFFE7)|(u16)StopBits;
}
/*******************************************************************************
* Function Name : UART_Config
* Description : This function configures the baudrate, the mode, the data
* parity and the number of stop bits of the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : The baudrate value
* Input 3 : The parity type
* Input 4 : The number of stop bits
* Input 5 : The UART mode
* Output : None
* Return : None
*******************************************************************************/
void UART_Config(UART_TypeDef *UARTx, u32 BaudRate, UARTParity_TypeDef Parity,
UARTStopBits_TypeDef StopBits, UARTMode_TypeDef Mode);
/*******************************************************************************
* Function Name : UART_ItConfig
* Description : This function enables or disables the interrupts of the
* selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : The new interrupt flag
* Input 3 : ENABLE or DISABLE
* Output : None
* Return : None
*******************************************************************************/
void UART_ItConfig(UART_TypeDef *UARTx, u16 UART_Flag, FunctionalState NewState);
/*******************************************************************************
* Function Name : UART_FifoConfig
* Description : This function enables or disables the Rx and Tx FIFOs of
* the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : ENABLE or DISABLE
* Output : None
* Return : None
*******************************************************************************/
void UART_FifoConfig(UART_TypeDef *UARTx, FunctionalState NewState);
/*******************************************************************************
* Function Name : UART_FifoReset
* Description : This function resets the Rx and the Tx FIFOs of the
* selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : RxFIFO or TxFIFO
* Output : None
* Return : None
*******************************************************************************/
void UART_FifoReset(UART_TypeDef *UARTx, UARTFIFO_TypeDef FIFO);
/*******************************************************************************
* Function Name : UART_LoopBackConfig
* Description : This function enables or disables the loop back mode of
* the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : ENABLE or DISABLE
* Output : None
* Return : None
*******************************************************************************/
void UART_LoopBackConfig(UART_TypeDef *UARTx, FunctionalState NewState);
/*******************************************************************************
* Function Name : UART_TimeOutPeriodConfig
* Description : This function configure the Time Out Period.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : The time-out period value
* Output : None
* Return : None
*******************************************************************************/
inline void UART_TimeOutPeriodConfig(UART_TypeDef *UARTx, u16 TimeOutPeriod)
{
UARTx->TOR = TimeOutPeriod;
}
/*******************************************************************************
* Function Name : UART_GuardTimeConfig
* Description : This function configure the Guard Time.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : The guard time value
* Output : None
* Return : None
*******************************************************************************/
inline void UART_GuardTimeConfig(UART_TypeDef *UARTx, u16 GuardTime)
{
UARTx->GTR = GuardTime;
}
/*******************************************************************************
* Function Name : UART_RxConfig
* Description : This function enable and disable the UART data reception.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : ENABLE or DISABLE
* Output : None
* Return : None
*******************************************************************************/
void UART_RxConfig(UART_TypeDef *UARTx, FunctionalState NewState);
/*******************************************************************************
* Function Name : UART_OnOffConfig
* Description : This function sets On/Off the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : ENABLE or DISABLE
* Output : None
* Return : None
*******************************************************************************/
void UART_OnOffConfig(UART_TypeDef *UARTx, FunctionalState NewState);
/*******************************************************************************
* Function Name : UART_ByteSend
* Description : This function sends a data byte to the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : A pointer to the data byte to send
* Output : None
* Return : None
*******************************************************************************/
void UART_ByteSend(UART_TypeDef *UARTx, u8 *Data);
/*******************************************************************************
* Function Name : UART_9BitByteSend
* Description : This function sends a 9 bits data byte to the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : A pointer to the data to send
* Output : None
* Return : None
*******************************************************************************/
void UART_9BitByteSend(UART_TypeDef *UARTx, u16 *Data);
/*******************************************************************************
* Function Name : UART_DataSend
* Description : This function sends several data bytes to the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : A pointer to the data to send
* Input 3 : The data length in bytes
* Output : None
* Return : None
*******************************************************************************/
void UART_DataSend(UART_TypeDef *UARTx, u8 *Data, u8 DataLength);
/*******************************************************************************
* Function Name : UART_9BitDataSend
* Description : This function sends several 9 bits data bytes to the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : A pointer to the data to send
* Input 3 : The data length
* Output : None
* Return : None
*******************************************************************************/
void UART_9BitDataSend(UART_TypeDef *UARTx, u16 *Data, u8 DataLength);
/*******************************************************************************
* Function Name : UART_StringSend
* Description : This function sends a string to the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : A pointer to the string to send
* Output : None
* Return : None
*******************************************************************************/
void UART_StringSend(UART_TypeDef *UARTx, u8 *String);
/*******************************************************************************
* Function Name : UART_ByteReceive
* Description : This function gets a data byte from the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : A pointer to the buffer where the data will be stored
* Input 3 : The time-out period
* Output : The received data
* Return : The UARTx.SR register contents
*******************************************************************************/
u16 UART_ByteReceive(UART_TypeDef *UARTx, u8 *Data, u8 TimeOut);
/*******************************************************************************
* Function Name : UART_9BitByteReceive
* Description : This function gets a 9 bits data byte from the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : A pointer to the buffer where the data will be stored
* Input 3 : The time-out period value
* Output : The received data
* Return : The UARTx.SR register contents
*******************************************************************************/
u16 UART_9BitByteReceive(UART_TypeDef *UARTx, u16 *Data, u8 TimeOut);
/*******************************************************************************
* Function Name : UART_DataReceive
* Description : This function gets 8 bits data bytes from the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : A pointer to the buffer where the data will be stored
* Input 3 : The data length
* Input 4 : The time-out period value
* Output : The received data
* Return : The UARTx.SR register contents
*******************************************************************************/
u16 UART_DataReceive(UART_TypeDef *UARTx, u8 *Data, u8 DataLength, u8 TimeOut);
/*******************************************************************************
* Function Name : UART_9BitDataReceive
* Description : This function gets 9 bits data bytes from the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : A pointer to the buffer where the data will be stored
* Input 3 : The data length
* Input 4 : The time-out value
* Output : The received data
* Return : The UARTx.SR register contents
*******************************************************************************/
u16 UART_9BitDataReceive(UART_TypeDef *UARTx, u16 *Data, u8 DataLength, u8 TimeOut);
/*******************************************************************************
* Function Name : UART_StringReceive
* Description : This function gets 8 bits data bytes from the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Input 2 : A pointer to the buffer where the string will be stored
* Output : None
* Return : None
*******************************************************************************/
u16 UART_StringReceive(UART_TypeDef *UARTx, u8 *Data);
/*******************************************************************************
* Function Name : UART_FlagStatus
* Description : This function gets the flags status of the selected UART.
* Input 1 : UARTx (x can be 0,1, 2 or 3) the desired UART
* Output : None
* Return : None
*******************************************************************************/
inline u16 UART_FlagStatus(UART_TypeDef *UARTx)
{
return UARTx->SR;
}
#ifdef USE_SERIAL_PORT
/*******************************************************************************
* Function Name : sendchar
* Description : This function sends a character to the selected UART.
* Input 1 : A pointer to the character to send.
* Output : None
* Return : None
*******************************************************************************/
void sendchar( char *ch );
#endif /* USE_SERIAL_PORT */
#endif /* _UART_H */
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,129 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : wdg.h
* Author : MCD Application Team
* Date First Issued : 25/08/2003
* Description : This file contains all the functions prototypes for the
* WDG software library.
********************************************************************************
* History:
* 30/11/2004 : V2.0
* 14/07/2004 : V1.3
* 01/01/2004 : V1.2
*******************************************************************************
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __WDG_H
#define __WDG_H
#include "71x_map.h"
#include "rccu.h"
/*******************************************************************************
* Function Name : WDG_Enable
* Description : Enable the Watchdog Mode
* Input : None
* Return : None
*******************************************************************************/
inline void WDG_Enable ( void )
{
WDG->CR |= 0x01;
}
/*******************************************************************************
* Function Name : WDG_CntRefresh
* Description : Refresh and update the WDG counter to avoid a system reset.
* Input : None
* Return : None
*******************************************************************************/
inline void WDG_CntRefresh ( void )
{
//write the first value in the key register
WDG->KR = 0xA55A;
//write the consecutive value
WDG->KR = 0x5AA5;
}
/*******************************************************************************
* Function Name : WDG_PrescalerConfig
* Description : Set the counter prescaler value.
* Divide the counter clock by (Prescaler + 1)
* Input : Prescaler data value (8 bit)
* Return : None
*******************************************************************************/
inline void WDG_PrescalerConfig ( u8 Prescaler )
{
WDG->PR = Prescaler;
}
/*******************************************************************************
* Function Name : WDG_CntReloadUpdate
* Description : Update the counter pre-load value.
* Input : Pre-load data value (16 bit)
* Return : None
*******************************************************************************/
inline void WDG_CntReloadUpdate ( u16 PreLoadValue )
{
WDG->VR = PreLoadValue;
}
/*******************************************************************************
* Function Name : WDG_PeriodValueConfig
* Description : Set the prescaler and counter reload value based on the
* time needed
* Input : Amount of time (us) needed, peripheral clock2 value
* Return : None
*******************************************************************************/
void WDG_PeriodValueConfig ( u32 Time );
/*******************************************************************************
* Function Name : WDG_CntOnOffConfig
* Description : Start or stop the free auto-reload timer to countdown.
* Input : ENABLE or DISABLE
* Return : None
*******************************************************************************/
inline void WDG_CntOnOffConfig ( FunctionalState NewState )
{
if (NewState == ENABLE) WDG->CR |= 0x0002; else WDG->CR &= ~0x0002;
}
/*******************************************************************************
* Function Name : WDG_ECITConfig
* Description : Enable or Disable the end of count interrupt
* Input : ENABLE or DISABLE
* Return : None
*******************************************************************************/
inline void WDG_ECITConfig (FunctionalState NewState)
{
if (NewState == ENABLE) WDG->MR |= 0x0001; else WDG->MR &= ~0x0001;
}
/*******************************************************************************
* Function Name : WDG_ECFlagClear
* Description : Clear the end of count flag
* Input : None
* Return : None
*******************************************************************************/
inline void WDG_ECFlagClear ( void )
{
WDG->SR = 0x0000;
}
/*******************************************************************************
* Function Name : WDG_ECStatus
* Description : Return the end of count status
* Input : None
* Return : NewState value
*******************************************************************************/
inline u16 WDG_ECStatus ( void )
{
return WDG->SR;
}
#endif // __WDG_H
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/