made a copy

This commit is contained in:
Richard Barry 2008-02-13 10:36:35 +00:00
parent bb7dc7c37f
commit e20f132f48
2632 changed files with 751681 additions and 0 deletions

View file

@ -0,0 +1,297 @@
;******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
;* File Name : 71x_init.s
;* Author : MCD Application Team
;* Date First Issued : 06/23/2004
;* Description : This is the first code executed after RESET.
;* This code used to initialize system stacks
;* and critical peripherals before entering the C code.
;*******************************************************************************
;* History:
;* 13/01/2006 : V3.1
;* 24/05/2005 : V3.0
;* 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.
;*******************************************************************************/
; --- Standard definitions of mode bits and interrupt (I & F) flags in PSRs
Mode_USR EQU 0x10
Mode_FIQ EQU 0x11
Mode_IRQ EQU 0x12
Mode_SVC EQU 0x13
Mode_ABT EQU 0x17
Mode_UNDEF EQU 0x1B
Mode_SYS EQU 0x1F ; available on ARM Arch 4 and later
I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled
F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled
EIC_Base_addr EQU 0xFFFFF800; EIC base address
ICR_off_addr EQU 0x00 ; Interrupt Control register offset
CIPR_off_addr EQU 0x08 ; Current Interrupt Priority Register offset
IVR_off_addr EQU 0x18 ; Interrupt Vector Register offset
FIR_off_addr EQU 0x1C ; Fast Interrupt Register offset
IER_off_addr EQU 0x20 ; Interrupt Enable Register offset
IPR_off_addr EQU 0x40 ; Interrupt Pending Bit Register offset
SIR0_off_addr EQU 0x60 ; Source Interrupt Register 0
EMI_Base_addr EQU 0x6C000000; EMI base address
BCON0_off_addr EQU 0x00 ; Bank 0 configuration register offset
BCON1_off_addr EQU 0x04 ; Bank 1 configuration register offset
BCON2_off_addr EQU 0x08 ; Bank 2 configuration register offset
BCON3_off_addr EQU 0x0C ; Bank 3 configuration register offset
EMI_ENABLE EQU 0x8000
EMI_SIZE_16 EQU 0x0001
GPIO2_Base_addr EQU 0xE0005000; GPIO2 base address
PC0_off_addr EQU 0x00 ; Port Configuration Register 0 offset
PC1_off_addr EQU 0x04 ; Port Configuration Register 1 offset
PC2_off_addr EQU 0x08 ; Port Configuration Register 2 offset
PD_off_addr EQU 0x0C ; Port Data Register offset
CPM_Base_addr EQU 0xA0000040; CPM Base Address
BOOTCR_off_addr EQU 0x10 ; CPM - Boot Configuration Register
FLASH_mask EQU 0x0000 ; to remap FLASH at 0x0
RAM_mask EQU 0x0002 ; to remap RAM at 0x0
;|----------------------------------------------------------------------------------|
;| - APB Bridge (System Peripheral) |
;|----------------------------------------------------------------------------------|
APB1_base_addr EQU 0xC0000000 ; APB Bridge1 Base Address
APB2_base_addr EQU 0xE0000000 ; APB Bridge2 Base Address
CKDIS_off_addr EQU 0x10 ; APB Bridge1 - Clock Disable Register
SWRES_off_addr EQU 0x14 ; APB Bridge1 - Software Reset Register
CKDIS1_config_all EQU 0x27FB ; To enable/disable clock of all APB1's peripherals
SWRES1_config_all EQU 0x27FB ; To reset all APB1's peripherals
CKDIS2_config_all EQU 0x7FDD ; To enable/disable clock of all APB2's peripherals
SWRES2_config_all EQU 0x7FDD ; To reset all APB2's peripherals
;---------------------------------------------------------------
; ?program_start
;---------------------------------------------------------------
MODULE ?program_start
SECTION IRQ_STACK:DATA:NOROOT(3)
SECTION FIQ_STACK:DATA:NOROOT(3)
SECTION UND_STACK:DATA:NOROOT(3)
SECTION ABT_STACK:DATA:NOROOT(3)
SECTION SVC_STACK:DATA:NOROOT(3)
SECTION CSTACK:DATA:NOROOT(3)
SECTION .text:CODE(2)
PUBLIC __iar_program_start
EXTERN ?main
EXTERN ?main
CODE32
;*******************************************************************************
;******* -- MACROS -- *******
;*******************************************************************************
;*******************************************************************************
;* Macro Name : EMI_INIT
;* Description : This macro Initialize EMI bank 1: 16-bit 7 wait state
;* Input : None.
;* Output : None.
;*******************************************************************************
EMI_INIT MACRO
LDR r0, =GPIO2_Base_addr ; Configure P2.0 -> 3 in AF_PP mode
LDR r2, [r0, #PC0_off_addr]
ORR r2, r2,#0x0000000F
STR r2, [r0, #PC0_off_addr]
LDR r2, [r0, #PC1_off_addr]
ORR r2, r2,#0x0000000F
STR r2, [r0, #PC1_off_addr]
LDR r2, [r0, #PC2_off_addr]
ORR r2, r2,#0x0000000F
STR r2, [r0, #PC2_off_addr]
LDR r0, =EMI_Base_addr
LDR r1, =0x18|EMI_ENABLE|EMI_SIZE_16
STR r1, [r0, #BCON1_off_addr] ; Enable bank 1 16-bit 7 wait state
ENDM
;*******************************************************************************
;* Macro Name : EIC_INIT
;* Description : This macro Initialize the EIC as following :
; - IRQ disabled
; - FIQ disabled
; - IVR contain the load PC opcode (0xE59FFXXX)
; - Current priority level equal to 0
; - All channels are disabled
; - All channels priority equal to 0
; - All SIR registers contain offset to the related IRQ
; table entry
;* Input : None.
;* Output : None.
;*******************************************************************************
EIC_INIT MACRO
LDR r3, =EIC_Base_addr
LDR r4, =0xE59F0000
STR r4, [r3, #IVR_off_addr]; Write the LDR pc,[pc,#offset]
; instruction code in IVR[31:16]
LDR r2, =32 ; 32 Channel to initialize
LDR r0, =T0TIMI_Addr ; Read the address of the IRQs
; address table
LDR r1, =0x00000FFF
AND r0,r0,r1
LDR r5, =SIR0_off_addr ; Read SIR0 address
SUB r4,r0,#8 ; subtract 8 for prefetch
LDR r1, =0xF7E8 ; Add the offset from IVR to 0x00000000
; address(IVR address + 7E8 = 0x00000000)
; 0xF7E8 used to complete the
; LDR pc,[pc,#offset] opcode (0xE59FFXXX)
ADD r1,r4,r1 ; Compute the jump offset from IVR to the
; IRQ table entry.
EIC_INI MOV r4, r1, LSL #16 ; Left shift the result
STR r4, [r3, r5] ; Store the result in SIRx register
ADD r1, r1, #4 ; Next IRQ address
ADD r5, r5, #4 ; Next SIR
SUBS r2, r2, #1 ; Decrement the number of SIR registers
; to initialize
BNE EIC_INI ; If more then continue
ENDM
;*******************************************************************************
;* Macro Name : PERIPHERAL_INIT
;* Description : This macro reset all device peripherals.
;* Input : None.
;* Output : None.
;*******************************************************************************
PERIPHERAL_INIT MACRO
LDR r1, =APB1_base_addr ; r0= APB1 base address
LDR r2, =APB2_base_addr ; r0= APB2 base address
LDR r0, =CKDIS1_config_all
STRH r0, [r1, #CKDIS_off_addr]; Clock Disabling for all APB1 peripherals
LDR r0, =CKDIS2_config_all
STRH r0, [r2, #CKDIS_off_addr]; Clock Disabling for all APB2 peripherals
LDR r0, =SWRES1_config_all
STRH r0, [r1, #SWRES_off_addr]; Keep all APB1 peripherals under reset
LDR r0, =SWRES2_config_all
STRH r0, [r2, #SWRES_off_addr]; Keep all APB2 peripherals under reset
MOV r7, #10 ; Wait that the selected macrocells exit from reset
loop1 SUBS r7, r7, #1
BNE loop1
MOV r0, #0
STRH r0, [r1, #SWRES_off_addr]; Enable all all APB1 peripherals
STRH r0, [r2, #SWRES_off_addr]; Enable all all APB2 peripherals
STRH r0, [r1, #CKDIS_off_addr]; Clock Enabling for all APB1 peripherals
STRH r0, [r2, #CKDIS_off_addr]; Clock Enabling for all APB2 peripherals
MOV r7, #10 ; Wait that the selected macrocells exit from reset
loop2 SUBS r7, r7, #1
BNE loop2
ENDM
;********************************************************************************************
; define remapping
; If you need to remap memory before entring the main program
; uncomment next ligne
; #define remapping
; Then define which memory to remap to address 0x00000000
; Uncomment next line if you want to remap RAM
; #define remap_ram
; Uncomment next line if you want to remap FLASH
; #define remap_flash
IMPORT T0TIMI_Addr
__iar_program_start
LDR pc, =NextInst
NextInst
NOP ; Wait for OSC stabilization
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
MSR CPSR_c, #Mode_ABT|F_Bit|I_Bit
ldr sp,=SFE(ABT_STACK) ; End of ABT_STACK
MSR CPSR_c, #Mode_UNDEF|F_Bit|I_Bit
ldr sp,=SFE(UND_STACK) ; End of UNDEF_STACK
MSR CPSR_c, #Mode_SVC|F_Bit|I_Bit
ldr sp,=SFE(SVC_STACK) ; End of SVC_STACK
; Uncomment next ligne if you need to reset all device pripherals
; PERIPHERAL_INIT ; Reset all device peripherals
; Uncomment next ligne if you need to enable the EMI Bank 1
; EMI_INIT ; Initialize EIM Bank 1
;Uncomment next ligne if you need to initialize the EIC
EIC_INIT ; Initialize EIC
;******************************************************************************
;REMAPPING
;Description : Remapping memory whether RAM,FLASH
; at Address 0x0 after the application has started executing.
; Remapping is generally done to allow RAM to replace FLASH
; at 0x0.
; the remapping of RAM allow copying of vector table into RAM
; To enable the memory remapping uncomment: (see above)
; #define remapping to enable memory remapping
; AND
; #define remap_ram to remap RAM
; OR
; #define remap_flash to remap FLASH
;******************************************************************************
#ifdef remapping
#ifdef remap_flash
MOV r0, #FLASH_mask
#endif
#ifdef remap_ram
MOV r0, #RAM_mask
#endif
LDR r1, =CPM_Base_addr
LDRH r2, [r1, #BOOTCR_off_addr]; Read BOOTCR Register
BIC r2, r2, #0x03 ; Reset the two LSB bits of BOOTCR
ORR r2, r2, r0 ; change the two LSB bits of BOOTCR
STRH r2, [r1, #BOOTCR_off_addr]; Write BOOTCR Register
#endif
MSR CPSR_c, #Mode_FIQ|I_Bit; Change to FIQ mode
ldr sp,=SFE(FIQ_STACK) ; End of FIQ_STACK
MSR CPSR_c, #Mode_IRQ|I_Bit; Change to IRQ mode
ldr sp,=SFE(IRQ_STACK) ; End of IRQ_STACK
MSR CPSR_c, #Mode_SYS ; Change to system mode, Enable IRQ and FIQ
ldr sp,=SFE(CSTACK) ; End of CSTACK(user)
; --- Now branches to a C lib function that copies RO data from their
; load region to their execute region, create the RW and ZI regions
; then jumps to user C main program.
; main() must be called from Supervisor mode
MSR CPSR_c, #Mode_SVC|F_Bit|I_Bit
b ?main ; Note : use B not BL, because an application will
; never return this way
LTORG
END
;******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****

View file

@ -0,0 +1,253 @@
#include "FreeRTOSConfig.h"
;******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
;* File Name : 71x_vect.s
;* Author : MCD Application Team
;* Date First Issued : 16/05/2003
;* Description : This file used to initialize the exception and IRQ
;* vectors, and to enter/return to/from exceptions handlers.
;*******************************************************************************
;* History:
;* 13/01/2006 : V3.1
;* 24/05/2005 : V3.0
;* 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.
;*******************************************************************************/
MODULE ?RESET
SECTION .intvec:CODE(2)
CODE32
EIC_base_addr EQU 0xFFFFF800; EIC base address.
CICR_off_addr EQU 0x04 ; Current Interrupt Channel Register.
IVR_off_addr EQU 0x18 ; Interrupt Vector Register.
IPR_off_addr EQU 0x40 ; Interrupt Pending Register.
;*******************************************************************************
; Import the __iar_program_start address from 71x_init.s
;*******************************************************************************
IMPORT __iar_program_start
;*******************************************************************************
; Import exception handlers
;*******************************************************************************
IMPORT Undefined_Handler
IMPORT Prefetch_Handler
IMPORT Abort_Handler
IMPORT FIQ_Handler
;*******************************************************************************
; Import IRQ handlers from 71x_it.c
;*******************************************************************************
IMPORT Default_Handler
IMPORT vPortYieldProcessor
IMPORT vSerialISREntry
IMPORT vPortPreemptiveTickISR
IMPORT vPortNonPreemptiveTick
;*******************************************************************************
; Export Peripherals IRQ handlers table address
;*******************************************************************************
EXPORT T0TIMI_Addr
;*******************************************************************************
; Exception vectors
;*******************************************************************************
IVR_ADDR DEFINE 0xFFFFF818
LDR PC, Reset_Addr
LDR PC, Undefined_Addr
LDR PC, SWI_Addr
LDR PC, Prefetch_Addr
LDR PC, Abort_Addr
NOP ; Reserved vector
LDR PC, =IVR_ADDR
LDR PC, FIQ_Addr
;*******************************************************************************
; Exception handlers address table
;*******************************************************************************
Reset_Addr DCD __iar_program_start
Undefined_Addr DCD UndefinedHandler
SWI_Addr DCD vPortYieldProcessor
Prefetch_Addr DCD PrefetchAbortHandler
Abort_Addr DCD DataAbortHandler
DCD 0 ; Reserved vector
IRQ_Addr DCD 0 ; Direct vectors are used. See the STR75x demo for an alternative implementation
FIQ_Addr DCD FIQHandler
;*******************************************************************************
; Peripherals IRQ handlers address table
;*******************************************************************************
T0TIMI_Addr DCD Default_Handler
FLASH_Addr DCD Default_Handler
RCCU_Addr DCD Default_Handler
RTC_Addr DCD Default_Handler
#if configUSE_PREEMPTION == 0
WDG_Addr DCD vPortNonPreemptiveTick ; Tick ISR if the cooperative scheduler is used.
#else
WDG_Addr DCD vPortPreemptiveTickISR ; Tick ISR if the preemptive scheduler is used.
#endif
XTI_Addr DCD Default_Handler
USBHP_Addr DCD Default_Handler
I2C0ITERR_Addr DCD Default_Handler
I2C1ITERR_ADDR DCD Default_Handler
UART0_Addr DCD vSerialISREntry
UART1_Addr DCD Default_Handler
UART2_ADDR DCD Default_Handler
UART3_ADDR DCD Default_Handler
BSPI0_ADDR DCD Default_Handler
BSPI1_Addr DCD Default_Handler
I2C0_Addr DCD Default_Handler
I2C1_Addr DCD Default_Handler
CAN_Addr DCD Default_Handler
ADC12_Addr DCD Default_Handler
T1TIMI_Addr DCD Default_Handler
T2TIMI_Addr DCD Default_Handler
T3TIMI_Addr DCD Default_Handler
DCD 0 ; reserved
DCD 0 ; reserved
DCD 0 ; reserved
HDLC_Addr DCD Default_Handler
USBLP_Addr DCD Default_Handler
DCD 0 ; reserved
DCD 0 ; reserved
T0TOI_Addr DCD Default_Handler
T0OC1_Addr DCD Default_Handler
T0OC2_Addr DCD Default_Handler
;*******************************************************************************
; Exception Handlers
;*******************************************************************************
;*******************************************************************************
;* Macro Name : SaveContext
;* Description : This macro used to save the context before entering
; an exception handler.
;* Input : The range of registers to store.
;* Output : none
;*******************************************************************************
SaveContext MACRO reg1,reg2
STMFD sp!,{reg1-reg2,lr} ; Save The workspace plus the current return
; address lr_ mode into the stack.
MRS r1,spsr ; Save the spsr_mode into r1.
STMFD sp!,{r1} ; Save spsr.
ENDM
;*******************************************************************************
;* Macro Name : RestoreContext
;* Description : This macro used to restore the context to return from
; an exception handler and continue the program execution.
;* Input : The range of registers to restore.
;* Output : none
;*******************************************************************************
RestoreContext MACRO reg1,reg2
LDMFD sp!,{r1} ; Restore the saved spsr_mode into r1.
MSR spsr_cxsf,r1 ; Restore spsr_mode.
LDMFD sp!,{reg1-reg2,pc}^; Return to the instruction following...
; ...the exception interrupt.
ENDM
;*******************************************************************************
;* Function Name : UndefinedHandler
;* Description : This function called when undefined instruction
; exception is entered.
;* Input : none
;* Output : none
;*******************************************************************************
UndefinedHandler
SaveContext r0,r12 ; Save the workspace plus the current
; return address lr_ und and spsr_und.
ldr r0,=Undefined_Handler
ldr lr,=Undefined_Handler_end
bx r0 ; Branch to Undefined_Handler
Undefined_Handler_end:
RestoreContext r0,r12 ; Return to the instruction following...
; ...the undefined instruction.
;*******************************************************************************
;* Function Name : PrefetchAbortHandler
;* Description : This function called when Prefetch Abort
; exception is entered.
;* Input : none
;* Output : none
;*******************************************************************************
PrefetchAbortHandler
SUB lr,lr,#4 ; Update the link register.
SaveContext r0,r12 ; Save the workspace plus the current
; return address lr_abt and spsr_abt.
ldr r0,=Prefetch_Handler
ldr lr,=Prefetch_Handler_end
bx r0 ; Branch to Prefetch_Handler.
Prefetch_Handler_end:
RestoreContext r0,r12 ; Return to the instruction following that...
; ...has generated the prefetch abort exception.
;*******************************************************************************
;* Function Name : DataAbortHandler
;* Description : This function is called when Data Abort
; exception is entered.
;* Input : none
;* Output : none
;*******************************************************************************
DataAbortHandler
SUB lr,lr,#8 ; Update the link register.
SaveContext r0,r12 ; Save the workspace plus the current
; return address lr_ abt and spsr_abt.
ldr r0,=Abort_Handler
ldr lr,=Abort_Handler_end
bx r0 ; Branch to Abort_Handler.
Abort_Handler_end:
RestoreContext r0,r12 ; Return to the instruction following that...
; ...has generated the data abort exception.
;*******************************************************************************
;* Function Name : FIQHandler
;* Description : This function is called when FIQ
; exception is entered.
;* Input : none
;* Output : none
;*******************************************************************************
FIQHandler
SUB lr,lr,#4 ; Update the link register.
SaveContext r0,r7 ; Save the workspace plus the current
; return address lr_ fiq and spsr_fiq.
ldr r0,=FIQ_Handler
ldr lr,=FIQ_Handler_end
bx r0 ; Branch to FIQ_Handler.
FIQ_Handler_end:
RestoreContext r0,r7 ; Restore the context and return to the...
; ...program execution.
LTORG
END
;******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****

View file

@ -0,0 +1,85 @@
/*
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
This file is part of the FreeRTOS.org distribution.
FreeRTOS.org is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FreeRTOS.org is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeRTOS.org; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes FreeRTOS.org, without being obliged to provide
the source code for any proprietary components. See the licensing section
of http://www.FreeRTOS.org for full details of how and when the exception
can be applied.
***************************************************************************
Please ensure to read the configuration and relevant port sections of the
online documentation.
+++ http://www.FreeRTOS.org +++
Documentation, latest information, license and contact details.
+++ http://www.SafeRTOS.com +++
A version that is certified for use in safety critical systems.
+++ http://www.OpenRTOS.com +++
Commercial support, development, porting, licensing and training services.
***************************************************************************
*/
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
* Application specific definitions.
*
* These definitions should be adjusted for your particular hardware and
* application requirements.
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*----------------------------------------------------------*/
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 48000000 )
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 100 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) 20480 )
#define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#endif /* FREERTOS_CONFIG_H */

View file

@ -0,0 +1,78 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : 71x_it.c
* Author : MCD Application Team
* Date First Issued : 16/05/2003
* Description : Main Interrupt Service Routines
*******************************************************************************
* History:
* 24/05/05 : V3.0
* 30/11/04 : V2.0
* 16/05/03 : Created
*******************************************************************************
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.
*******************************************************************************/
#include "71x_it.h"
u32 counter=1;
/*******************************************************************************
* Function Name : Undefined_Handler
* Description : This function handles Undefined instruction exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void Undefined_Handler(void)
{
for( ;; );
}
/*******************************************************************************
* Function Name : FIQ_Handler
* Description : This function handles FIQ exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void FIQ_Handler(void)
{
for( ;; );
}
/*******************************************************************************
* Function Name : Prefetch_Handler
* Description : This function handles Prefetch Abort exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void Prefetch_Handler(void)
{
for( ;; );
}
/*******************************************************************************
* Function Name : Abort_Handler
* Description : This function handles Data Abort exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void Abort_Handler(void)
{
for( ;; );
}
void Default_Handler( void );
void Default_Handler( void )
{
for( ;; );
}
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,157 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : 71x_lib.c
* Author : MCD Application Team
* Date First Issued : 05/16/2003
* Description : Peripherals pointers initialization
********************************************************************************
* 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.
*******************************************************************************/
#define EXT
#include "71x_map.h"
#ifdef DEBUG
extern u32 T0TIMI_Addr;
/*******************************************************************************
* Function Name : debug
* Description : Initialize the pointers to peripherals
* Input : none
* Output : none
* Return : none
*******************************************************************************/
void debug(void)
{
#ifdef _ADC12
ADC12 = (ADC12_TypeDef *)ADC12_BASE;
#endif
#ifdef _APB
#ifdef _APB1
APB1 = (APB_TypeDef *)APB1_BASE;
#endif
#ifdef _APB2
APB2 = (APB_TypeDef *)APB2_BASE;
#endif
#endif
#ifdef _BSPI
#ifdef _BSPI0
BSPI0 = (BSPI_TypeDef *)BSPI0_BASE;
#endif
#ifdef _BSPI1
BSPI1 = (BSPI_TypeDef *)BSPI1_BASE;
#endif
#endif
#ifdef _CAN
CAN = (CAN_TypeDef *)CAN_BASE;
#endif
#ifdef _EIC
EIC = (EIC_TypeDef *)EIC_BASE;
#endif
#ifdef _EMI
EMI = (EMI_TypeDef *)EMI_BASE;
#endif
#ifdef _FLASH
FLASHR = (FLASHR_TypeDef *)FLASHR_BASE;
FLASHPR = (FLASHPR_TypeDef *)FLASHPR_BASE;
#endif
#ifdef _GPIO
#ifdef _GPIO0
GPIO0 = (GPIO_TypeDef *)GPIO0_BASE;
#endif
#ifdef _GPIO1
GPIO1 = (GPIO_TypeDef *)GPIO1_BASE;
#endif
#ifdef _GPIO2
GPIO2 = (GPIO_TypeDef *)GPIO2_BASE;
#endif
#endif
#ifdef _I2C
#ifdef _I2C0
I2C0 = (I2C_TypeDef *)I2C0_BASE;
#endif
#ifdef _I2C1
I2C1 = (I2C_TypeDef *)I2C1_BASE;
#endif
#endif
#ifdef _PCU
PCU = (PCU_TypeDef *)PCU_BASE;
#endif
#ifdef _RCCU
RCCU = (RCCU_TypeDef *)RCCU_BASE;
#endif
#ifdef _RTC
RTC = (RTC_TypeDef *)RTC_BASE;
#endif
#ifdef _TIM
#ifdef _TIM0
TIM0 = (TIM_TypeDef *)TIM0_BASE;
#endif
#ifdef _TIM1
TIM1 = (TIM_TypeDef *)TIM1_BASE;
#endif
#ifdef _TIM2
TIM2 = (TIM_TypeDef *)TIM2_BASE;
#endif
#ifdef _TIM3
TIM3 = (TIM_TypeDef *)TIM3_BASE;
#endif
#endif
#ifdef _UART
#ifdef _UART0
UART0 = (UART_TypeDef *)UART0_BASE;
#endif
#ifdef _UART1
UART1 = (UART_TypeDef *)UART1_BASE;
#endif
#ifdef _UART2
UART2 = (UART_TypeDef *)UART2_BASE;
#endif
#ifdef _UART3
UART3 = (UART_TypeDef *)UART3_BASE;
#endif
#endif
#ifdef _USB
USB = (USB_TypeDef *)USB_BASE;
#endif
#ifdef _WDG
WDG = (WDG_TypeDef *)WDG_BASE;
#endif
#ifdef _XTI
XTI = (XTI_TypeDef *)XTI_BASE;
#endif
#ifdef _IRQVectors
IRQVectors = (IRQVectors_TypeDef *)&T0TIMI_Addr;
#endif
}
#endif /* DEBUG */
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,114 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : gpio.c
* Author : MCD Application Team
* Date First Issued : 06/08/2003
* Description : This file provides all the GPIO software functions
********************************************************************************
* 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.
*******************************************************************************/
#include "gpio.h"
/*******************************************************************************
* 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)
{
switch (GPIO_Mode)
{
case GPIO_HI_AIN_TRI:
GPIOx->PC0&=~Port_Pins;
GPIOx->PC1&=~Port_Pins;
GPIOx->PC2&=~Port_Pins;
break;
case GPIO_IN_TRI_TTL:
GPIOx->PC0|=Port_Pins;
GPIOx->PC1&=~Port_Pins;
GPIOx->PC2&=~Port_Pins;
break;
case GPIO_IN_TRI_CMOS:
GPIOx->PC0&=~Port_Pins;
GPIOx->PC1|=Port_Pins;
GPIOx->PC2&=~Port_Pins;
break;
case GPIO_IPUPD_WP:
GPIOx->PC0|=Port_Pins;
GPIOx->PC1|=Port_Pins;
GPIOx->PC2&=~Port_Pins;
break;
case GPIO_OUT_OD:
GPIOx->PC0&=~Port_Pins;
GPIOx->PC1&=~Port_Pins;
GPIOx->PC2|=Port_Pins;
break;
case GPIO_OUT_PP:
GPIOx->PC0|=Port_Pins;
GPIOx->PC1&=~Port_Pins;
GPIOx->PC2|=Port_Pins;
break;
case GPIO_AF_OD:
GPIOx->PC0&=~Port_Pins;
GPIOx->PC1|=Port_Pins;
GPIOx->PC2|=Port_Pins;
break;
case GPIO_AF_PP:
GPIOx->PC0|=Port_Pins;
GPIOx->PC1|=Port_Pins;
GPIOx->PC2|=Port_Pins;
break;
}
}
/*******************************************************************************
* 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)
{
if (Port_Val&0x01) GPIOx->PD |= 1<<Port_Pin; else GPIOx->PD &= ~(1<<Port_Pin);
}
/*******************************************************************************
* 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)
{
GPIOx->PD = Port_Byte ? (GPIOx->PD&0x00FF) | ((u16)Port_Val<<8)
: (GPIOx->PD&0xFF00) | Port_Val;
}
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

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****/

View file

@ -0,0 +1,183 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : rccu.c
* Author : MCD Application Team
* Date First Issued : 07/28/2003
* Description : This file provides all the RCCU software functions
********************************************************************************
* 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.
*******************************************************************************/
#include "rccu.h"
/*******************************************************************************
* Function Name : RCCU_PLL1Config
* Description : Configures the PLL1 div & mul factors.
* Input : New_Mul ( RCCU_PLL1_Mul_12, RCCU_PLL1_Mul_16, RCCU_PLL1_Mul_20,
* RCCU_PLL1_Mul_24 )
* : 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 )
{
u32 Tmp = ( RCCU->PLL1CR & ~RCCU_MX_Mask ) | ( New_Mul << RCCU_MX_Index );
RCCU->PLL1CR = ( Tmp & ~RCCU_DX_Mask ) | New_Div | 0x40;
}
/*******************************************************************************
* Function Name : RCCU_PLL2Config
* Description : Configures the PLL2 div & mul factors.
* Input : New_Mul ( RCCU_PLL2_Mul_12, RCCU_PLL2_Mul_16, RCCU_PLL2_Mul_20,
* RCCU_Mul_PLL2_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 )
{
u32 Tmp = ( PCU->PLL2CR & ~RCCU_MX_Mask ) | ( New_Mul << RCCU_MX_Index );
PCU->PLL2CR = ( Tmp & ~RCCU_DX_Mask ) | ( New_Div | RCCU_FREEN_Mask );
}
/*******************************************************************************
* 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 )
{
switch ( New_Clock )
{
case RCCU_CLOCK2 :{// Resets the CSU_Cksel bit in clk_flag
RCCU->CFR &= ~RCCU_CSU_CKSEL_Mask;
// Set the CK2_16 Bit in the CFR
RCCU->CFR |= RCCU_CK2_16_Mask;
// Deselect The CKAF
RCCU->CCR &= ~RCCU_CKAF_SEL_Mask;
// switch off the PLL1
RCCU->PLL1CR=((RCCU->PLL1CR & ~RCCU_DX_Mask)\
|0x00000003) & ~RCCU_FREEN_Mask;
break;}
case RCCU_CLOCK2_16 :{// ReSet the CK2_16 Bit in the CFR
RCCU->CFR &= ~RCCU_CK2_16_Mask;
// Deselect The CKAF
RCCU->CCR &= ~RCCU_CKAF_SEL_Mask;
// switch off the PLL1
RCCU->PLL1CR=((RCCU->PLL1CR & ~RCCU_DX_Mask)\
|0x00000003) & ~RCCU_FREEN_Mask;
break;}
case RCCU_PLL1_Output:{// Set the CK2_16 Bit in the CFR
RCCU->CFR = RCCU->CFR | RCCU_CK2_16_Mask;
// Waits the PLL1 to lock if DX bits are different from '111'
// If all DX bit are set the PLL lock flag in meaningless
if (( RCCU->PLL1CR & 0x0007 ) != 7)
while(!(RCCU->CFR & RCCU_LOCK_Mask));
// Deselect The CKAF
RCCU->CCR &= ~RCCU_CKAF_SEL_Mask;
// Select The CSU_CKSEL
RCCU->CFR |= RCCU_CSU_CKSEL_Mask;
break;}
case RCCU_RTC_CLOCK : {RCCU->CCR |= 0x04;
break;}
}
}
/*******************************************************************************
* Function Name : RCCU_RCLKClockSource
* Description : Returns the current RCLK source clock
* Input : None
* Return : RCCU_PLL1_Output, RCCU_CLOCK2_16, RCCU_CLOCK2, RCCU_RTC_CLOCK
*******************************************************************************/
RCCU_RCLK_Clocks RCCU_RCLKClockSource ( void )
{
if ((RCCU->CCR & 0x04)==0x04)
return RCCU_RTC_CLOCK;
else if ((RCCU->CFR & RCCU_CK2_16_Mask)==0)
return RCCU_CLOCK2_16;
else if (RCCU->CFR & RCCU_CSU_CKSEL_Mask)
return RCCU_PLL1_Output;
else
return RCCU_CLOCK2;
}
/*******************************************************************************
* Function Name : RCCU_USBClockSource
* Description : Gets the RCLK source clock
* Input : None
* Return : RCCU_USB_Clocks ( RCCU_PLL2_Output, RCCU_USBCK )
*******************************************************************************/
RCCU_USB_Clocks RCCU_USBClockSource ( void )
{
if ((PCU->PLL2CR & RCCU_USBEN_Mask ) >> RCCU_USBEN_Index == 1 )
return RCCU_PLL2_Output;
else return RCCU_USBCK;
}
/*******************************************************************************
* Function Name : RCCU_FrequencyValue
* Description : Calculates & Returns any internal RCCU clock frequency
* 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 )
{
u32 Tmp;
u8 Div, Mul;
RCCU_RCLK_Clocks CurrentRCLK;
Tmp = ( RCCU_Div2Status() == SET )? RCCU_Main_Osc / 2 : RCCU_Main_Osc;
if ( Internal_Clk == RCCU_CLK2 )
{
Div = 1;
Mul = 1;
}
else
{ CurrentRCLK = RCCU_RCLKClockSource ();
switch ( CurrentRCLK ){
case RCCU_CLOCK2_16 : Div = 16;
Mul = 1;
break;
case RCCU_CLOCK2 : Div = 1;
Mul = 1;
break;
case RCCU_PLL1_Output :{Mul=(RCCU->PLL1CR & RCCU_MX_Mask ) >> RCCU_MX_Index;
switch ( Mul )
{case 0: Mul = 20; break;
case 1: Mul = 12; break;
case 2: Mul = 28; break;
case 3: Mul = 16; break;
}
Div = ( RCCU->PLL1CR & RCCU_DX_Mask ) + 1;
break;}
case RCCU_RTC_CLOCK : Mul = 1;
Div = 1;
Tmp = RCCU_RTC_Osc;
break;}}
switch ( Internal_Clk ){
case RCCU_MCLK :{Div <<= PCU->MDIVR & RCCU_FACT_Mask;
break;}
case RCCU_PCLK :{Div <<=(PCU->PDIVR & RCCU_FACT2_Mask ) >> RCCU_FACT2_Index;
break;}
case RCCU_FCLK :{Div <<= PCU->PDIVR & 0x3;
break;}}
return (Tmp * Mul) / Div;
}
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,365 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : uart.c
* Author : MCD Application Team
* Date First Issued : 06/08/2003
* Description : This file provides all the UART software functions
********************************************************************************
* 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.
*******************************************************************************/
#include "uart.h"
/*******************************************************************************
* 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)
{
UARTx->IER = 0x00;
UARTx->CR = 0x00;
(void)UARTx->RxBUFR;
UARTx->RxRSTR = 0xFFFF;
UARTx->TxRSTR = 0xFFFF;
}
/*******************************************************************************
* 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)
{
UARTx->BR = (u16)(RCCU_FrequencyValue(RCCU_FCLK)/(16*BaudRate));
}
/*******************************************************************************
* 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)
{
UART_ModeConfig(UARTx, Mode);
UART_BaudRateConfig(UARTx, BaudRate);
UART_ParityConfig(UARTx, Parity);
UART_StopBitsConfig(UARTx, StopBits);
}
/*******************************************************************************
* 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)
{
if (NewState==ENABLE) UARTx->IER|=UART_Flag; else UARTx->IER&=~UART_Flag;
}
/*******************************************************************************
* 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)
{
if (NewState==ENABLE) UARTx->CR|=0x0400; else UARTx->CR&=~0x0400;
}
/*******************************************************************************
* 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 : UART_RxFIFO or UART_TxFIFO
* Output : None
* Return : None
*******************************************************************************/
void UART_FifoReset(UART_TypeDef *UARTx, UARTFIFO_TypeDef FIFO)
{
if (FIFO==UART_RxFIFO) UARTx->RxRSTR=0xFFFF; else UARTx->TxRSTR=0xFFFF;
}
/*******************************************************************************
* 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)
{
if (NewState==ENABLE) UARTx->CR|=0x0040; else UARTx->CR&=~0x0040;
}
/*******************************************************************************
* Function Name : UART_RxConfig
* Description : This function enables or disables 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)
{
if (NewState==ENABLE) UARTx->CR|=0x0100; else UARTx->CR&=~0x0100;
}
/*******************************************************************************
* 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)
{
if (NewState==ENABLE) UARTx->CR|=0x0080; else UARTx->CR&=~0x0080;
}
/*******************************************************************************
* 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)
{
if (UARTx->CR & (0x0001<<UART_FIFOEnableBit))// if FIFO ENABLED
while((UARTx->SR & UART_TxFull)); // while the UART_TxFIFO contain 16 characters.
else // if FIFO DISABLED
while (!(UARTx->SR & UART_TxEmpty)); // while the transmit shift register not empty
UARTx->TxBUFR = *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)
{
if(UARTx->CR & (0x0001<<UART_FIFOEnableBit))// if FIFO ENABLED
while((UARTx->SR & UART_TxFull)); // while the UART_TxFIFO contain 16 characters.
else // if FIFO DISABLED
while (!(UARTx->SR & UART_TxEmpty)); // while the transmit shift register not empty
UARTx->TxBUFR = *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)
{
while(DataLength--)
{
UART_ByteSend(UARTx,Data);
Data++;
}
}
/*******************************************************************************
* 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)
{
while(DataLength--)
{
UART_9BitByteSend(UARTx,Data);
Data++;
}
}
/*******************************************************************************
* 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)
{
u8 *Data=String;
while(*Data != '\0')
UART_ByteSend(UARTx, Data++);
*Data='\0';
UART_ByteSend(UARTx, Data);
}
/*******************************************************************************
* 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)
{
u16 wStatus;
UARTx->TOR=TimeOut;// reload the Timeout counter
while (!((wStatus=UARTx->SR) & (UART_TimeOutIdle|UART_RxHalfFull|UART_RxBufFull)));// while the UART_RxFIFO is empty and no Timeoutidle
*Data = (u8)UARTx->RxBUFR; // then read the Receive Buffer Register
return wStatus;
}
/*******************************************************************************
* 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)
{
u16 wStatus;
UARTx->TOR=TimeOut;// reload the Timeout counter
while (!((wStatus=UARTx->SR) & (UART_TimeOutIdle|UART_RxHalfFull|UART_RxBufFull)));// while the UART_RxFIFO is empty and no Timeoutidle
*Data = (u16)UARTx->RxBUFR; // then read the RxBUFR
return wStatus;
}
/*******************************************************************************
* 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)
{
u16 wStatus;
while(DataLength--)
wStatus=UART_ByteReceive(UARTx,Data++,TimeOut);
return wStatus;
}
/*******************************************************************************
* 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)
{
u16 wStatus;
while(DataLength--)
wStatus=UART_9BitByteReceive(UARTx,Data++,TimeOut);
return wStatus;
}
/*******************************************************************************
* 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 : The received string
* Return : The UARTx.SR register contents
*******************************************************************************/
u16 UART_StringReceive(UART_TypeDef *UARTx, u8 *Data)
{
u8 *pSTRING=Data;
u16 wStatus;
do
{
while (!((wStatus=UARTx->SR) & (UART_RxHalfFull|UART_RxBufFull)));// while the UART_RxFIFO is empty and no Timeoutidle
*(pSTRING++) = (u8)UARTx->RxBUFR; // then read the RxBUFR
} while((*(pSTRING - 1)!=0x0D)&(*(pSTRING - 1)!='\0'));
*(pSTRING - 1)='\0';
return wStatus;
}
#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 )
{
#ifdef USE_UART0
#define UARTx UART0
#endif /* Use_UART0 */
#ifdef USE_UART1
#define UARTx UART1
#endif /* Use_UART1 */
#ifdef USE_UART2
#define UARTx UART2
#endif /* Use_UART2 */
#ifdef USE_UART3
#define UARTx UART3
#endif /* Use_UART3 */
UART_ByteSend(UARTx,(u8 *)ch);
}
#endif /* USE_SERIAL_PORT */
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,83 @@
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name : WDG.c
* Author : MCD Application Team
* Date First Issued : 10/24/2003
* Description : This file provides all the WDG software functions
********************************************************************************
* 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.
*******************************************************************************/
#include "wdg.h"
#ifndef abs
#define abs(x) ((x)>0 ? (x) : -(x))
#endif
/*******************************************************************************
* Function Name : FindFactors
* Description : Search for the best (a,b) values that fit n = a*b
* with the following constraints: 1<=a<=256, 1<=b<=65536
* Input 1 : n: the number to decompose
* Input/Output 2 : a: a pointer to the first factor
* Input/Output 3 : b: a pointer to the second factor
* Return : None
*******************************************************************************/
static void FindFactors(unsigned long n, unsigned int *a, unsigned long *b)
{
unsigned long b0;
unsigned int a0;
long err, err_min=n;
*a = a0 = ((n-1)/65536ul) + 1;
*b = b0 = n / *a;
for (; *a <= 256; (*a)++)
{
*b = n / *a;
err = (long)*a * (long)*b - (long)n;
if (abs(err) > (*a / 2))
{
(*b)++;
err = (long)*a * (long)*b - (long)n;
}
if (abs(err) < abs(err_min))
{
err_min = err;
a0 = *a;
b0 = *b;
if (err == 0) break;
}
}
*a = a0;
*b = b0;
}
/*******************************************************************************
* Function Name : WDG_PeriodValueConfig
* Description : Set the prescaler and counter reload value
* Input : Amount of time (us) needed
* Return : None
*******************************************************************************/
void WDG_PeriodValueConfig ( u32 Time )
{
unsigned int a;
unsigned long n, b;
n = Time * (RCCU_FrequencyValue(RCCU_PCLK) / 1000000);
FindFactors(n, &a, &b);
WDG->PR = a - 1;
WDG->VR = b - 1;
}
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,117 @@
/*
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
This file is part of the FreeRTOS.org distribution.
FreeRTOS.org is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FreeRTOS.org is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeRTOS.org; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes FreeRTOS.org, without being obliged to provide
the source code for any proprietary components. See the licensing section
of http://www.FreeRTOS.org for full details of how and when the exception
can be applied.
***************************************************************************
Please ensure to read the configuration and relevant port sections of the
online documentation.
+++ http://www.FreeRTOS.org +++
Documentation, latest information, license and contact details.
+++ http://www.SafeRTOS.com +++
A version that is certified for use in safety critical systems.
+++ http://www.OpenRTOS.com +++
Commercial support, development, porting, licensing and training services.
***************************************************************************
*/
/* Library includes. */
#include "GPIO.h"
/* Scheduler includes. */
#include "FreeRTOS.h"
/* Demo application includes. */
#include "partest.h"
/*-----------------------------------------------------------
* Simple parallel port IO routines for the LED's - which are
* connected to the second nibble of GPIO port 1.
*-----------------------------------------------------------*/
#define partstLED_3 0x0080
#define partstLED_2 0x0040
#define partstLED_1 0x0020
#define partstLED_0 0x0010
#define partstON_BOARD 0x0100 /* The LED built onto the KickStart board. */
#define partstALL_LEDs ( partstLED_0 | partstLED_1 | partstLED_2 | partstLED_3 | partstON_BOARD )
#define partstFIRST_LED_BIT 4
/* This demo application uses files that are common to all port demo
applications. These files assume 6 LED's are available, whereas I have
only 5 (including the LED built onto the development board). To prevent
two tasks trying to use the same LED a bit of remapping is performed.
The ComTest tasks will try and use LED's 6 and 7. LED 6 is ignored and
has no effect, LED 7 is mapped to LED3. The LED usage is described in
the port documentation available from the FreeRTOS.org WEB site. */
#define partstCOM_TEST_LED 7
#define partstRX_CHAR_LED 3
/*-----------------------------------------------------------*/
void vParTestInitialise( void )
{
/* Configure the bits used to flash LED's on port 1 as output. */
GPIO_Config(GPIO1, partstALL_LEDs, GPIO_OUT_OD);
}
/*-----------------------------------------------------------*/
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
{
if( uxLED == partstCOM_TEST_LED )
{
/* Remap as described above. */
uxLED = partstRX_CHAR_LED;
}
/* Adjust the LED value to map to the port pins actually being used,
then write the required value to the port. */
uxLED += partstFIRST_LED_BIT;
GPIO_BitWrite( GPIO1, uxLED, !xValue );
}
/*-----------------------------------------------------------*/
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{
if( uxLED == partstCOM_TEST_LED )
{
/* Remap as described above. */
uxLED = partstRX_CHAR_LED;
}
/* Adjust the LED value to map to the port pins actually being used,
then write the opposite value to the current state to the port pin. */
uxLED += partstFIRST_LED_BIT;
GPIO_BitWrite(GPIO1, uxLED, ~GPIO_BitRead( GPIO1, uxLED ) );
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<workspace>
<project>
<path>$WS_DIR$\RTOSDemo.ewp</path>
</project>
<batchBuild/>
</workspace>

View file

@ -0,0 +1,42 @@
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x40000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x4000062C;
define symbol __ICFEDIT_region_ROM_end__ = 0x4003FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x2000FFFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x200;
define symbol __ICFEDIT_size_svcstack__ = 0x100;
define symbol __ICFEDIT_size_irqstack__ = 0x200;
define symbol __ICFEDIT_size_fiqstack__ = 0x10;
define symbol __ICFEDIT_size_undstack__ = 0x10;
define symbol __ICFEDIT_size_abtstack__ = 0x10;
define symbol __ICFEDIT_size_heap__ = 0x4;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block SVC_STACK with alignment = 8, size = __ICFEDIT_size_svcstack__ { };
define block IRQ_STACK with alignment = 8, size = __ICFEDIT_size_irqstack__ { };
define block FIQ_STACK with alignment = 8, size = __ICFEDIT_size_fiqstack__ { };
define block UND_STACK with alignment = 8, size = __ICFEDIT_size_undstack__ { };
define block ABT_STACK with alignment = 8, size = __ICFEDIT_size_abtstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite,
block CSTACK, block SVC_STACK, block IRQ_STACK, block FIQ_STACK,
block UND_STACK, block ABT_STACK, block HEAP };

View file

@ -0,0 +1,256 @@
/*
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
This file is part of the FreeRTOS.org distribution.
FreeRTOS.org is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FreeRTOS.org is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeRTOS.org; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes FreeRTOS.org, without being obliged to provide
the source code for any proprietary components. See the licensing section
of http://www.FreeRTOS.org for full details of how and when the exception
can be applied.
***************************************************************************
Please ensure to read the configuration and relevant port sections of the
online documentation.
+++ http://www.FreeRTOS.org +++
Documentation, latest information, license and contact details.
+++ http://www.SafeRTOS.com +++
A version that is certified for use in safety critical systems.
+++ http://www.OpenRTOS.com +++
Commercial support, development, porting, licensing and training services.
***************************************************************************
*/
/*
NOTE : Tasks run in system mode and the scheduler runs in Supervisor mode.
The processor MUST be in supervisor mode when vTaskStartScheduler is
called. The demo applications included in the FreeRTOS.org download switch
to supervisor mode prior to main being called. If you are not using one of
these demo application projects then ensure Supervisor mode is used.
*/
/*
* Creates all the demo application tasks, then starts the scheduler. The WEB
* documentation provides more details of the demo application tasks.
*
* Main.c also creates a task called "Check". This only executes every three
* seconds but has the highest priority so is guaranteed to get processor time.
* Its main function is to check that all the other tasks are still operational.
* Each task (other than the "flash" tasks) maintains a unique count that is
* incremented each time the task successfully completes its function. Should
* any error occur within such a task the count is permanently halted. The
* check task inspects the count of each task to ensure it has changed since
* the last time the check task executed. If all the count variables have
* changed all the tasks are still executing error free, and the check task
* toggles the onboard LED. Should any task contain an error at any time
* the LED toggle rate will change from 3 seconds to 500ms.
*
*/
/* Library includes. */
#include "RCCU.h"
#include "wdg.h"
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
/* Demo application includes. */
#include "flash.h"
#include "integer.h"
#include "PollQ.h"
#include "BlockQ.h"
#include "semtest.h"
#include "dynamic.h"
#include "partest.h"
#include "comtest2.h"
/* Priorities for the demo application tasks. */
#define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
/* Constants required by the 'Check' task. */
#define mainNO_ERROR_FLASH_PERIOD ( ( portTickType ) 3000 / portTICK_RATE_MS )
#define mainERROR_FLASH_PERIOD ( ( portTickType ) 500 / portTICK_RATE_MS )
#define mainCHECK_TASK_LED ( 4 )
/* Constants for the ComTest tasks. */
#define mainCOM_TEST_BAUD_RATE ( ( unsigned portLONG ) 115200 )
#define mainCOM_TEST_LED ( 6 ) /* The LED built onto the kickstart board. */
/*
* The task that executes at the highest priority and calls
* prvCheckOtherTasksAreStillRunning(). See the description at the top
* of the file.
*/
static void vErrorChecks( void *pvParameters );
/*
* Configure the processor for use with the IAR STR71x demo board. This
* just sets the PLL for the required frequency.
*/
static void prvSetupHardware( void );
/*
* Checks that all the demo application tasks are still executing without error
* - as described at the top of the file. Called by vErrorChecks().
*/
static portLONG prvCheckOtherTasksAreStillRunning( void );
/*-----------------------------------------------------------*/
/*
* Starts all the other tasks, then starts the scheduler.
*/
void main( void )
{
/* Setup any hardware that has not already been configured by the low
level init routines. */
prvSetupHardware();
/* Initialise the LED outputs for use by the demo application tasks. */
vParTestInitialise();
/* Start all the standard demo application tasks. */
vStartIntegerMathTasks( tskIDLE_PRIORITY );
vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
vStartDynamicPriorityTasks();
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
/* Start the check task - which is defined in this file. */
xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* Start the scheduler.
NOTE : Tasks run in system mode and the scheduler runs in Supervisor mode.
The processor MUST be in supervisor mode when vTaskStartScheduler is
called. The demo applications included in the FreeRTOS.org download switch
to supervisor mode prior to main being called. If you are not using one of
these demo application projects then ensure Supervisor mode is used here. */
vTaskStartScheduler();
/* We should never get here as control is now taken by the scheduler. */
return;
}
/*-----------------------------------------------------------*/
static void prvSetupHardware( void )
{
/* Setup the PLL to generate a 48MHz clock from the 4MHz CLK. */
/* Turn of the div by two. */
RCCU_Div2Config( DISABLE );
/* 48MHz = ( 4MHz * 12 ) / 1 */
RCCU_PLL1Config( RCCU_PLL1_Mul_12, RCCU_Div_1 );
RCCU_RCLKSourceConfig( RCCU_PLL1_Output );
}
/*-----------------------------------------------------------*/
static void vErrorChecks( void *pvParameters )
{
portTickType xDelayPeriod = mainNO_ERROR_FLASH_PERIOD;
portTickType xLastWakeTime;
/* The parameters are not used in this task. */
( void ) pvParameters;
/* Initialise xLastWakeTime to ensure the first call to vTaskDelayUntil()
functions correctly. */
xLastWakeTime = xTaskGetTickCount();
/* Cycle for ever, delaying then checking all the other tasks are still
operating without error. If an error is detected then the delay period
is decreased from mainNO_ERROR_FLASH_PERIOD to mainERROR_FLASH_PERIOD so
the on board LED flash rate will increase. */
for( ;; )
{
/* Delay until it is time to execute again. The delay period is
shorter following an error so the LED flashes faster. */
vTaskDelayUntil( &xLastWakeTime, xDelayPeriod );
/* Check all the standard demo application tasks are executing without
error. */
if( prvCheckOtherTasksAreStillRunning() != pdPASS )
{
/* An error has been detected in one of the tasks - flash faster. */
xDelayPeriod = mainERROR_FLASH_PERIOD;
}
vParTestToggleLED( mainCHECK_TASK_LED );
}
}
/*-----------------------------------------------------------*/
static portLONG prvCheckOtherTasksAreStillRunning( void )
{
portLONG lReturn = ( portLONG ) pdPASS;
/* Check all the demo tasks (other than the flash tasks) to ensure
that they are all still running, and that none of them have detected
an error. */
if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
{
lReturn = ( portLONG ) pdFAIL;
}
if( xArePollingQueuesStillRunning() != pdTRUE )
{
lReturn = ( portLONG ) pdFAIL;
}
if( xAreSemaphoreTasksStillRunning() != pdTRUE )
{
lReturn = ( portLONG ) pdFAIL;
}
if( xAreBlockingQueuesStillRunning() != pdTRUE )
{
lReturn = ( portLONG ) pdFAIL;
}
if( xAreComTestTasksStillRunning() != pdTRUE )
{
lReturn = ( portLONG ) pdFAIL;
}
if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
{
lReturn = ( portLONG ) pdFAIL;
}
return lReturn;
}
/*-----------------------------------------------------------*/

View file

@ -0,0 +1,252 @@
/*
FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.
This file is part of the FreeRTOS.org distribution.
FreeRTOS.org is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FreeRTOS.org is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeRTOS.org; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
A special exception to the GPL can be applied should you wish to distribute
a combined work that includes FreeRTOS.org, without being obliged to provide
the source code for any proprietary components. See the licensing section
of http://www.FreeRTOS.org for full details of how and when the exception
can be applied.
***************************************************************************
Please ensure to read the configuration and relevant port sections of the
online documentation.
+++ http://www.FreeRTOS.org +++
Documentation, latest information, license and contact details.
+++ http://www.SafeRTOS.com +++
A version that is certified for use in safety critical systems.
+++ http://www.OpenRTOS.com +++
Commercial support, development, porting, licensing and training services.
***************************************************************************
*/
/*
BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER FOR UART0.
*/
/* Library includes. */
#include "uart.h"
#include "gpio.h"
#include "eic.h"
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "queue.h"
/* Demo application includes. */
#include "serial.h"
#define UART0_Rx_Pin ( 0x0001<< 8 )
#define UART0_Tx_Pin ( 0x0001<< 9 )
#define serINVALID_QUEUE ( ( xQueueHandle ) 0 )
#define serNO_BLOCK ( ( portTickType ) 0 )
/* Macros to turn on and off the Tx empty interrupt. */
#define serINTERRUPT_ON() UART0->IER |= UART_TxHalfEmpty
#define serINTERRUPT_OFF() UART0->IER &= ~UART_TxHalfEmpty
/*-----------------------------------------------------------*/
/* Queues used to hold received characters, and characters waiting to be
transmitted. */
static xQueueHandle xRxedChars;
static xQueueHandle xCharsForTx;
/*-----------------------------------------------------------*/
/* Interrupt entry point written in the assembler file serialISR.s79. */
extern void vSerialISREntry( void );
/* The interrupt service routine - called from the assembly entry point. */
__arm void vSerialISR( void );
/*-----------------------------------------------------------*/
/*
* See the serial2.h header file.
*/
xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
xComPortHandle xReturn;
/* Create the queues used to hold Rx and Tx characters. */
xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
/* If the queues were created correctly then setup the serial port
hardware. */
if( ( xRxedChars != serINVALID_QUEUE ) && ( xCharsForTx != serINVALID_QUEUE ) )
{
portENTER_CRITICAL();
{
/* Setup the UART port pins. */
GPIO_Config( GPIO0, UART0_Tx_Pin, GPIO_AF_PP );
GPIO_Config( GPIO0, UART0_Rx_Pin, GPIO_IN_TRI_CMOS );
/* Configure the UART. */
UART_OnOffConfig( UART0, ENABLE );
UART_FifoConfig( UART0, DISABLE );
UART_FifoReset( UART0, UART_RxFIFO );
UART_FifoReset( UART0, UART_TxFIFO );
UART_LoopBackConfig(UART0, DISABLE );
UART_Config( UART0, ulWantedBaud, UART_NO_PARITY, UART_1_StopBits, UARTM_8D );
UART_RxConfig( UART0, ENABLE );
/* Configure the IEC for the UART interrupts. */
EIC_IRQChannelPriorityConfig( UART0_IRQChannel, 1 );
EIC_IRQChannelConfig( UART0_IRQChannel, ENABLE );
EIC_IRQConfig( ENABLE );
UART_ItConfig( UART0, UART_RxBufFull, ENABLE );
}
portEXIT_CRITICAL();
}
else
{
xReturn = ( xComPortHandle ) 0;
}
/* This demo file only supports a single port but we have to return
something to comply with the standard demo header file. */
return xReturn;
}
/*-----------------------------------------------------------*/
signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed portCHAR *pcRxedChar, portTickType xBlockTime )
{
/* The port handle is not required as this driver only supports one port. */
( void ) pxPort;
/* Get the next character from the buffer. Return false if no characters
are available, or arrive before xBlockTime expires. */
if( xQueueReceive( xRxedChars, pcRxedChar, xBlockTime ) )
{
return pdTRUE;
}
else
{
return pdFALSE;
}
}
/*-----------------------------------------------------------*/
void vSerialPutString( xComPortHandle pxPort, const signed portCHAR * const pcString, unsigned portSHORT usStringLength )
{
signed portCHAR *pxNext;
/* A couple of parameters that this port does not use. */
( void ) usStringLength;
( void ) pxPort;
/* NOTE: This implementation does not handle the queue being full as no
block time is used! */
/* The port handle is not required as this driver only supports UART0. */
( void ) pxPort;
/* Send each character in the string, one at a time. */
pxNext = ( signed portCHAR * ) pcString;
while( *pxNext )
{
xSerialPutChar( pxPort, *pxNext, serNO_BLOCK );
pxNext++;
}
}
/*-----------------------------------------------------------*/
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed portCHAR cOutChar, portTickType xBlockTime )
{
/* Place the character in the queue of characters to be transmitted. */
if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS )
{
return pdFAIL;
}
/* Turn on the Tx interrupt so the ISR will remove the character from the
queue and send it. This does not need to be in a critical section as
if the interrupt has already removed the character the next interrupt
will simply turn off the Tx interrupt again. */
serINTERRUPT_ON();
return pdPASS;
}
/*-----------------------------------------------------------*/
void vSerialClose( xComPortHandle xPort )
{
/* Not supported as not required by the demo application. */
}
/*-----------------------------------------------------------*/
/* Serial port ISR. This can cause a context switch so is not defined as a
standard ISR using the __irq keyword. Instead a wrapper function is defined
within serialISR.s79 which in turn calls this function. See the port
documentation on the FreeRTOS.org website for more information. */
__arm void vSerialISR( void )
{
unsigned portSHORT usStatus;
signed portCHAR cChar;
portBASE_TYPE xTaskWokenByTx = pdFALSE, xTaskWokenByPost = pdFALSE;
/* What caused the interrupt? */
usStatus = UART_FlagStatus( UART0 );
if( usStatus & UART_TxHalfEmpty )
{
/* The interrupt was caused by the THR becoming empty. Are there any
more characters to transmit? */
if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xTaskWokenByTx ) == pdTRUE )
{
/* A character was retrieved from the queue so can be sent to the
THR now. */
UART0->TxBUFR = cChar;
}
else
{
/* Queue empty, nothing to send so turn off the Tx interrupt. */
serINTERRUPT_OFF();
}
}
if( usStatus & UART_RxBufFull )
{
/* The interrupt was caused by a character being received. Grab the
character from the RHR and place it in the queue of received
characters. */
cChar = UART0->RxBUFR;
xTaskWokenByPost = xQueueSendFromISR( xRxedChars, &cChar, xTaskWokenByPost );
}
/* If a task was woken by either a character being received or a character
being transmitted then we may need to switch to another task. */
portEND_SWITCHING_ISR( ( xTaskWokenByPost || xTaskWokenByTx ) );
/* End the interrupt in the EIC. */
portCLEAR_EIC();
}

View file

@ -0,0 +1,24 @@
RSEG ICODE:CODE
CODE32
EXTERN vSerialISR
PUBLIC vSerialISREntry
; Wrapper for the serial port interrupt service routine. This can cause a
; context switch so requires an assembly wrapper.
; Defines the portSAVE_CONTEXT and portRESTORE_CONTEXT macros.
#include "ISR_Support.h"
vSerialISREntry:
portSAVE_CONTEXT ; Save the context of the current task.
bl vSerialISR ; Call the ISR routine.
portRESTORE_CONTEXT ; Restore the context of the current task -
; which may be different to the task that
; was interrupted.
END

View file

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<Project>
<Desktop>
<Static>
<Workspace>
<ColumnWidths>
<Column0>273</Column0><Column1>27</Column1><Column2>27</Column2><Column3>27</Column3></ColumnWidths>
</Workspace>
<Disassembly>
<PreferedWindows>
<Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows>
<CodeCovEnabled>0</CodeCovEnabled><MixedMode>1</MixedMode><CodeCovShow>0</CodeCovShow></Disassembly>
<Debug-Log/>
<Build>
<ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1153</ColumnWidth1><ColumnWidth2>307</ColumnWidth2><ColumnWidth3>76</ColumnWidth3></Build>
<Register><PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></Register><Breakpoints/></Static>
<Windows>
<Wnd3>
<Tabs>
<Tab>
<Identity>TabID-24393-22702</Identity>
<TabName>Workspace</TabName>
<Factory>Workspace</Factory>
<Session>
<NodeDict><ExpandedNode>RTOSDemo</ExpandedNode><ExpandedNode>RTOSDemo/Demo Source</ExpandedNode><ExpandedNode>RTOSDemo/RTOS Source</ExpandedNode><ExpandedNode>RTOSDemo/System Files</ExpandedNode><ExpandedNode>RTOSDemo/System Files/vect.s79</ExpandedNode></NodeDict></Session>
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab></Wnd3><Wnd4>
<Tabs>
<Tab>
<Identity>TabID-13122-22708</Identity>
<TabName>Debug Log</TabName>
<Factory>Debug-Log</Factory>
<Session/>
</Tab>
<Tab>
<Identity>TabID-23870-22711</Identity>
<TabName>Build</TabName>
<Factory>Build</Factory>
<Session/>
</Tab>
<Tab><Identity>TabID-19116-28152</Identity><TabName>Breakpoints</TabName><Factory>Breakpoints</Factory><Session/></Tab></Tabs>
<SelectedTab>0</SelectedTab></Wnd4><Wnd5><Tabs><Tab><Identity>TabID-10802-25870</Identity><TabName>Disassembly</TabName><Factory>Disassembly</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd5></Windows>
<Editor>
<Pane><Tab><Factory>TextEditor</Factory><Filename>C:\E\Dev\FreeRTOS\Demo\ARM7_STR71x_IAR\main.c</Filename><XPos>0</XPos><YPos>104</YPos><SelStart>4900</SelStart><SelEnd>4900</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>C:\E\Dev\FreeRTOS\Demo\ARM7_STR71x_IAR\Library\71x_it.c</Filename><XPos>0</XPos><YPos>48</YPos><SelStart>2578</SelStart><SelEnd>2578</SelEnd></Tab><ActiveTab>1</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Positions>
<Top><Row0><Sizes><Toolbar-01284260><key>iaridepm.enu1</key></Toolbar-01284260><Toolbar-0a3cb9d0><key>debuggergui.enu1</key></Toolbar-0a3cb9d0></Sizes></Row0></Top><Left><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>746</Bottom><Right>347</Right><x>-2</x><y>-2</y><xscreen>109</xscreen><yscreen>110</yscreen><sizeHorzCX>77857</sizeHorzCX><sizeHorzCY>112016</sizeHorzCY><sizeVertCX>249286</sizeVertCX><sizeVertCY>761711</sizeVertCY></Rect></Wnd3></Sizes></Row0></Left><Right><Row0><Sizes><Wnd5><Rect><Top>-2</Top><Left>-2</Left><Bottom>746</Bottom><Right>198</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>142857</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>142857</sizeVertCX><sizeVertCY>761711</sizeVertCY></Rect></Wnd5></Sizes></Row0></Right><Bottom><Row0><Sizes><Wnd4><Rect><Top>-2</Top><Left>-2</Left><Bottom>192</Bottom><Right>1402</Right><x>-2</x><y>-2</y><xscreen>1404</xscreen><yscreen>194</yscreen><sizeHorzCX>1002857</sizeHorzCX><sizeHorzCY>197556</sizeHorzCY><sizeVertCX>77857</sizeVertCX><sizeVertCY>112016</sizeVertCY></Rect></Wnd4></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop>
</Project>

View file

@ -0,0 +1,39 @@
[DisAssemblyWindow]
NumStates=_ 1
State 1=_ 1
[JLinkDriver]
WatchVectorCatch=_ 0
WatchCond=_ 0
Watch0=_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0
Watch1=_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0
[Low Level]
Pipeline mode=0
Initialized=0
[CodeCoverage]
Enabled=_ 0
[Profiling]
Enabled=0
[StackPlugin]
Enabled=1
OverflowWarningsEnabled=1
WarningThreshold=90
SpWarningsEnabled=1
WarnHow=0
UseTrigger=1
TriggerName=main
LimitSize=0
ByteLimit=50
[Log file]
LoggingEnabled=_ 0
LogFile=_ ""
Category=_ 0
[TermIOLog]
LoggingEnabled=_ 0
LogFile=_ ""
[Disassemble mode]
mode=0
[Breakpoints]
Count=0
[TraceHelper]
Enabled=0
ShowSource=1

View file

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<Workspace>
<ConfigDictionary>
<CurrentConfigs><Project>RTOSDemo/Release</Project></CurrentConfigs></ConfigDictionary>
<Desktop>
<Static>
<Workspace>
<ColumnWidths>
<Column0>189</Column0><Column1>27</Column1><Column2>27</Column2><Column3>27</Column3></ColumnWidths>
</Workspace>
<Build>
<ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1153</ColumnWidth1><ColumnWidth2>307</ColumnWidth2><ColumnWidth3>76</ColumnWidth3></Build>
<TerminalIO/>
<Profiling/>
<Debug-Log/>
<CodeCoveragePlugin/><Breakpoints/><Disassembly><MixedMode>1</MixedMode><CodeCovShow>0</CodeCovShow></Disassembly></Static>
<Windows>
<Wnd3>
<Tabs>
<Tab>
<Identity>TabID-14962-21036</Identity>
<TabName>Workspace</TabName>
<Factory>Workspace</Factory>
<Session>
<NodeDict><ExpandedNode>RTOSDemo</ExpandedNode><ExpandedNode>RTOSDemo/source</ExpandedNode></NodeDict></Session>
</Tab>
</Tabs>
<SelectedTab>0</SelectedTab></Wnd3><Wnd4>
<Tabs>
<Tab>
<Identity>TabID-24623-22493</Identity>
<TabName>Build</TabName>
<Factory>Build</Factory>
<Session/>
</Tab>
<Tab>
<Identity>TabID-13645-22698</Identity>
<TabName>Debug Log</TabName>
<Factory>Debug-Log</Factory>
<Session/>
</Tab>
<Tab><Identity>TabID-25855-25419</Identity><TabName>Breakpoints</TabName><Factory>Breakpoints</Factory><Session/></Tab></Tabs>
<SelectedTab>0</SelectedTab></Wnd4></Windows>
<Editor>
<Pane><Tab><Factory>TextEditor</Factory><Filename>C:\E\Dev\FreeRTOS\Demo\ARM7_STR71x_IAR\main.c</Filename><XPos>0</XPos><YPos>104</YPos><SelStart>4900</SelStart><SelEnd>4900</SelEnd></Tab><ActiveTab>0</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>
<Positions>
<Top><Row0><Sizes><Toolbar-01284260><key>iaridepm.enu1</key></Toolbar-01284260></Sizes></Row0><Row1><Sizes/></Row1></Top><Left><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>590</Bottom><Right>263</Right><x>-2</x><y>-2</y><xscreen>18</xscreen><yscreen>18</yscreen><sizeHorzCX>12857</sizeHorzCX><sizeHorzCY>18330</sizeHorzCY><sizeVertCX>189286</sizeVertCX><sizeVertCY>602851</sizeVertCY></Rect></Wnd3></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd4><Rect><Top>-2</Top><Left>-2</Left><Bottom>348</Bottom><Right>1402</Right><x>-2</x><y>-2</y><xscreen>1404</xscreen><yscreen>350</yscreen><sizeHorzCX>1002857</sizeHorzCX><sizeHorzCY>356415</sizeHorzCY><sizeVertCX>12857</sizeVertCX><sizeVertCY>18330</sizeVertCY></Rect></Wnd4></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>
</Desktop>
</Workspace>