mirror of
https://github.com/FreeRTOS/FreeRTOS.git
synced 2026-02-06 10:41:44 +08:00
Add STM32 Primer demo. Remove the .lock file from the Eclipse demos.
This commit is contained in:
93
Demo/CORTEX_STM32F103_Primer_GCC/FreeRTOSConfig.h
Normal file
93
Demo/CORTEX_STM32F103_Primer_GCC/FreeRTOSConfig.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 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.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com a version that has been certified for use
|
||||
in safety critical systems, plus commercial licensing, development and
|
||||
support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
/* Library includes. */
|
||||
#include "stm32f10x_lib.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 1
|
||||
#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 72000000 )
|
||||
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
|
||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 128 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 17 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
#define configUSE_TRACE_FACILITY 0
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 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 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
|
||||
/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255
|
||||
(lowest) to 0 (1?) (highest). */
|
||||
#define configKERNEL_INTERRUPT_PRIORITY 255
|
||||
|
||||
/* This is the value being used as per the ST library which permits 16
|
||||
priority values, 0 to 15. This must correspond to the
|
||||
configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest
|
||||
NVIC value of 255. */
|
||||
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
|
||||
121
Demo/CORTEX_STM32F103_Primer_GCC/ParTest/ParTest.c
Normal file
121
Demo/CORTEX_STM32F103_Primer_GCC/ParTest/ParTest.c
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 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.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com a version that has been certified for use
|
||||
in safety critical systems, plus commercial licensing, development and
|
||||
support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Simple parallel port IO routines.
|
||||
*-----------------------------------------------------------*/
|
||||
|
||||
/* FreeRTOS.org includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "partest.h"
|
||||
|
||||
#define partstMAX_OUTPUT_LED ( 2 )
|
||||
#define partstFIRST_LED GPIO_Pin_8
|
||||
|
||||
static unsigned portSHORT usOutputValue = 0;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestInitialise( void )
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
/* Enable LED GPIO clock. */
|
||||
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE );
|
||||
|
||||
/* Configure LED pins as output push-pull. */
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 ;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
|
||||
GPIO_Init( GPIOB, &GPIO_InitStructure );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
|
||||
{
|
||||
unsigned portSHORT usBit;
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
if( uxLED < partstMAX_OUTPUT_LED )
|
||||
{
|
||||
usBit = partstFIRST_LED << uxLED;
|
||||
|
||||
if( xValue == pdFALSE )
|
||||
{
|
||||
usBit ^= ( unsigned portSHORT ) 0xffff;
|
||||
usOutputValue &= usBit;
|
||||
}
|
||||
else
|
||||
{
|
||||
usOutputValue |= usBit;
|
||||
}
|
||||
|
||||
GPIO_Write( GPIOB, usOutputValue );
|
||||
}
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
|
||||
{
|
||||
unsigned portSHORT usBit;
|
||||
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
if( uxLED < partstMAX_OUTPUT_LED )
|
||||
{
|
||||
usBit = partstFIRST_LED << uxLED;
|
||||
|
||||
if( usOutputValue & usBit )
|
||||
{
|
||||
usOutputValue &= ~usBit;
|
||||
}
|
||||
else
|
||||
{
|
||||
usOutputValue |= usBit;
|
||||
}
|
||||
|
||||
GPIO_Write( GPIOB, usOutputValue );
|
||||
}
|
||||
}
|
||||
xTaskResumeAll();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
577
Demo/CORTEX_STM32F103_Primer_GCC/RTOSDemo-globals.Standard.xml
Normal file
577
Demo/CORTEX_STM32F103_Primer_GCC/RTOSDemo-globals.Standard.xml
Normal file
File diff suppressed because it is too large
Load Diff
2278
Demo/CORTEX_STM32F103_Primer_GCC/RTOSDemo.Standard.xml
Normal file
2278
Demo/CORTEX_STM32F103_Primer_GCC/RTOSDemo.Standard.xml
Normal file
File diff suppressed because it is too large
Load Diff
108
Demo/CORTEX_STM32F103_Primer_GCC/RTOSDemo.rapp
Normal file
108
Demo/CORTEX_STM32F103_Primer_GCC/RTOSDemo.rapp
Normal file
@@ -0,0 +1,108 @@
|
||||
|
||||
<ApplicationBuild Header="RTOSDemo" Extern=".\RTOSDemo.rapp" Path=".\RTOSDemo.rapp" OutputFile=".\RTOSDemo.elf" sate="98" >
|
||||
<Group Header="ST_Library" Marker="-1" OutputFile="" sate="96" >
|
||||
<NodeC Path=".\ST_Code\led.c" Header="led.c" Marker="-1" OutputFile=".\led.o" sate="0" >
|
||||
<Options> </Options>
|
||||
|
||||
</NodeC>
|
||||
<NodeC Path=".\ST_Code\crt0_STM32x.c" Header="crt0_STM32x.c" Marker="-1" OutputFile=".\crt0_STM32x.o" sate="0" >
|
||||
<Options> </Options>
|
||||
|
||||
</NodeC>
|
||||
<NodeC Path=".\ST_Code\lcd.c" Header="lcd.c" Marker="-1" OutputFile=".\lcd.o" sate="0" >
|
||||
<Options> </Options>
|
||||
|
||||
</NodeC>
|
||||
<NodeC Path=".\ST_Code\Util.c" Header="Util.c" Marker="-1" OutputFile=".\Util.o" sate="0" >
|
||||
<Options> </Options>
|
||||
|
||||
</NodeC>
|
||||
<NodeC Path=".\ST_Code\draw.c" Header="draw.c" Marker="-1" OutputFile=".\draw.o" sate="0" >
|
||||
<Options> </Options>
|
||||
|
||||
</NodeC>
|
||||
<NodeC Path=".\ST_Code\mems.c" Header="mems.c" Marker="-1" OutputFile=".\mems.o" sate="0" />
|
||||
<NodeH Path=".\ST_Code\stm32f10x_conf.h" Header="stm32f10x_conf.h" Marker="-1" OutputFile="" sate="0" />
|
||||
<NodeC Path=".\ST_Code\buzzer.c" Header="buzzer.c" Marker="-1" OutputFile=".\buzzer.o" sate="0" />
|
||||
<NodeC Path=".\ST_Code\pointer.c" Header="pointer.c" Marker="-1" OutputFile=".\pointer.o" sate="0" />
|
||||
|
||||
</Group>
|
||||
<Group Header="Demo_Source" Marker="-1" OutputFile="" sate="96" >
|
||||
<NodeC Path=".\main.c" Header="main.c" Marker="-1" OutputFile=".\main.o" sate="0" />
|
||||
<NodeC Path=".\ParTest\ParTest.c" Header="ParTest.c" Marker="-1" OutputFile=".\ParTest.o" sate="0" />
|
||||
<NodeH Path=".\FreeRTOSConfig.h" Header="FreeRTOSConfig.h" Marker="-1" OutputFile="" sate="0" />
|
||||
<NodeC Path=".\timertest.c" Header="timertest.c" Marker="-1" OutputFile=".\timertest.o" sate="0" />
|
||||
<NodeC Path=".\printf-stdarg.c" Header="printf-stdarg.c" Marker="-1" OutputFile=".\printf-stdarg.o" sate="0" >
|
||||
<Options/>
|
||||
|
||||
</NodeC>
|
||||
<NodeC Path="..\Common\Minimal\GenQTest.c" Header="GenQTest.c" Marker="-1" OutputFile=".\GenQTest.o" sate="0" />
|
||||
<NodeC Path="..\Common\Minimal\BlockQ.c" Header="BlockQ.c" Marker="-1" OutputFile=".\BlockQ.o" sate="0" />
|
||||
<NodeC Path="..\Common\Minimal\blocktim.c" Header="blocktim.c" Marker="-1" OutputFile=".\blocktim.o" sate="0" />
|
||||
<NodeC Path="..\Common\Minimal\QPeek.c" Header="QPeek.c" Marker="-1" OutputFile=".\QPeek.o" sate="0" />
|
||||
<NodeC Path="..\Common\Minimal\PollQ.c" Header="PollQ.c" Marker="-1" OutputFile=".\PollQ.o" sate="0" />
|
||||
|
||||
</Group>
|
||||
<Group Header="FreeRTOS.org_Source" Marker="-1" OutputFile="" sate="96" >
|
||||
<NodeC Path="..\..\Source\tasks.c" Header="tasks.c" Marker="-1" OutputFile=".\tasks.o" sate="0" >
|
||||
<Options/>
|
||||
|
||||
</NodeC>
|
||||
<NodeC Path="..\..\Source\list.c" Header="list.c" Marker="-1" OutputFile=".\list.o" sate="0" >
|
||||
<Options/>
|
||||
|
||||
</NodeC>
|
||||
<NodeC Path="..\..\Source\queue.c" Header="queue.c" Marker="-1" OutputFile=".\queue.o" sate="0" >
|
||||
<Options/>
|
||||
|
||||
</NodeC>
|
||||
<NodeC Path="..\..\Source\portable\GCC\ARM_CM3\port.c" Header="port.c" Marker="-1" OutputFile=".\port.o" sate="0" />
|
||||
<NodeC Path="..\..\Source\portable\MemMang\heap_2.c" Header="heap_2.c" Marker="-1" OutputFile=".\heap_2.o" sate="0" />
|
||||
|
||||
</Group>
|
||||
<Options>
|
||||
<Config Header="Standard" >
|
||||
<Set Header="ApplicationBuild" >
|
||||
<Section Header="General" >
|
||||
<Property Header="TargetFamily" Value="ARM" />
|
||||
|
||||
</Section>
|
||||
<Section Header="Directories" >
|
||||
<Property Header="IncDir" Value="$(ApplicationDir)\..\..\Source\include;$(ApplicationDir)\..\Common\include;$(ApplicationDir)\ST_Code;$(RkitLib)\ARM\include;." Removable="1" />
|
||||
|
||||
</Section>
|
||||
|
||||
</Set>
|
||||
<Set Header="Target" >
|
||||
<Section Header="ProcessorARM" >
|
||||
<Property Header="Processor" Value="STM32F103RBT6" />
|
||||
|
||||
</Section>
|
||||
<Section Header="ToolSetARM" >
|
||||
<Property Header="BuildToolSetARM" Value="ARM\\GNU.config" Removable="1" />
|
||||
|
||||
</Section>
|
||||
|
||||
</Set>
|
||||
<Set Header="LD" >
|
||||
<Section Header="Startup" >
|
||||
<Property Header="DEFAULTSTARTUP" Value="No" Removable="1" />
|
||||
<Property Header="File" Value="" Removable="1" />
|
||||
|
||||
</Section>
|
||||
|
||||
</Set>
|
||||
<Set Header="GCC" >
|
||||
<Section Header="Defines" >
|
||||
<Property Header="Defines" Value="GCC_ARMCM3" Removable="1" />
|
||||
|
||||
</Section>
|
||||
<Section Header="OPTIMIZE" >
|
||||
<Property Header="Optimize" Value="-O1" Removable="1" />
|
||||
|
||||
</Section>
|
||||
|
||||
</Set>
|
||||
</Config>
|
||||
</Options>
|
||||
</ApplicationBuild>
|
||||
4
Demo/CORTEX_STM32F103_Primer_GCC/RTOSDemo.rprj
Normal file
4
Demo/CORTEX_STM32F103_Primer_GCC/RTOSDemo.rprj
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
<Project Header="Project 'RTOSDemo'" Path=".\RTOSDemo.rprj" Project="Yes" OutputFile="" sate="96" ActiveApp="RTOSDemo" >
|
||||
<ApplicationBuild Header="RTOSDemo" Extern=".\RTOSDemo.rapp" Path=".\RTOSDemo.rapp" OutputFile=".\RTOSDemo.elf" sate="98" ></ApplicationBuild>
|
||||
</Project>
|
||||
528
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/Util.c
Normal file
528
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/Util.c
Normal file
File diff suppressed because it is too large
Load Diff
18
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/adc.h
Normal file
18
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/adc.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/********************* (C) COPYRIGHT 2007 RAISONANCE S.A.S. *******************/
|
||||
/**
|
||||
*
|
||||
* @file adc.h
|
||||
* @brief ADC initialization header file.
|
||||
* @author FL
|
||||
* @date 07/2007
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion ---------------------------------------*/
|
||||
#ifndef __ADC_H
|
||||
#define __ADC_H
|
||||
|
||||
#define ADC1_DR_Address ((u32)0x4001244C)
|
||||
|
||||
#endif /*__ADC_H */
|
||||
554
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/buzzer.c
Normal file
554
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/buzzer.c
Normal file
File diff suppressed because it is too large
Load Diff
431
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/circle.h
Normal file
431
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/circle.h
Normal file
@@ -0,0 +1,431 @@
|
||||
/********************* (C) COPYRIGHT 2007 RAISONANCE S.A.S. *******************/
|
||||
/**
|
||||
*
|
||||
* @file circle.h
|
||||
* @brief General header for the CircleOS project.
|
||||
* @author FL
|
||||
* @date 07/2007
|
||||
* @version 1.5
|
||||
*
|
||||
* It contains the list of the utilities functions organized by sections
|
||||
* (MEMS, LCD, POINTER, ...)
|
||||
*
|
||||
* @date 10/2007
|
||||
* @version 1.5 types of OutX_F64 and OutX_F256 changed to u32 (same for Y and Z)
|
||||
**/
|
||||
/******************************************************************************/
|
||||
|
||||
#include "scheduler.h"
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __CIRCLE_H
|
||||
#define __CIRCLE_H
|
||||
|
||||
//-------------------------------- General -------------------------------------
|
||||
/* Defines ------------------------------------------------------------------*/
|
||||
#define VDD_VOLTAGE_MV 3300 //Voltage (mV) of the STM32
|
||||
#define FA_TABLE 0x8006000
|
||||
#define TIM2 ((TIM_TypeDef *) TIM2_BASE)
|
||||
#define CIRCLEOS_RAM_BASE 0x20004000
|
||||
|
||||
/* Variables ----------------------------------------------------------------*/
|
||||
extern GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
/* Utilities -----------------------------------------------------------------*/
|
||||
void UTIL_uint2str( char *ptr , u32 X, u16 digit, int fillwithzero );
|
||||
void UTIL_int2str( char *ptr , s32 X, u16 digit, int fillwithzero );
|
||||
u16 UTIL_ReadBackupRegister( u16 BKP_DR );
|
||||
void UTIL_WriteBackupRegister( u16 BKP_DR, u16 Data );
|
||||
u16 UTIL_GetBat( void );
|
||||
u8 UTIL_GetUsb( void );
|
||||
u16 UTIL_GetTemp ( void ) ;
|
||||
void UTIL_SetTempMode ( int mode );
|
||||
//typedef void (*tHandler) ( void );
|
||||
void UTIL_SetIrqHandler ( int , tHandler );
|
||||
tHandler UTIL_GetIrqHandler ( int );
|
||||
extern u16 ADC_ConvertedValue[17];
|
||||
|
||||
|
||||
extern enum eSpeed
|
||||
{
|
||||
SPEED_VERY_LOW = 1,
|
||||
SPEED_LOW = 2,
|
||||
SPEED_MEDIUM = 3,
|
||||
SPEED_HIGH = 4,
|
||||
SPEED_VERY_HIGH = 5
|
||||
} CurrentSpeed;
|
||||
|
||||
enum eSchHandler
|
||||
{
|
||||
LED_SCHHDL_ID = 0,
|
||||
BUTTON_SCHHDL_ID = 1,
|
||||
BUZZER_SCHHDL_ID = 2,
|
||||
MENU_SCHHDL_ID = 3,
|
||||
POINTER_SCHHDL_ID = 4,
|
||||
LCD_SCHHDL_ID = 5,
|
||||
DRAW_SCHHDL_ID = 6,
|
||||
RTC_SCHHDL_ID = 7,
|
||||
|
||||
UNUSED0_SCHHDL_ID = 8,
|
||||
UNUSED1_SCHHDL_ID = 9,
|
||||
UNUSED2_SCHHDL_ID = 10,
|
||||
UNUSED3_SCHHDL_ID = 11,
|
||||
UNUSED4_SCHHDL_ID = 12,
|
||||
UNUSED5_SCHHDL_ID = 13,
|
||||
UNUSED6_SCHHDL_ID = 14,
|
||||
UNUSED7_SCHHDL_ID = 15
|
||||
} dummy_var ; //for doxygen
|
||||
|
||||
void UTIL_SetSchHandler ( enum eSchHandler , tHandler );
|
||||
tHandler UTIL_GetSchHandler ( enum eSchHandler );
|
||||
#define NULL_SCHHDL (0)
|
||||
#define LAST_SCHHDL ((tHandler)(-1))
|
||||
|
||||
|
||||
void UTIL_SetPll( enum eSpeed speed );
|
||||
const char* UTIL_GetVersion( void );
|
||||
enum eSpeed UTIL_GetPll( void );
|
||||
extern RCC_ClocksTypeDef RCC_ClockFreq;
|
||||
extern u8 fTemperatureInFahrenheit; /*!< 1 : Fahrenheit, 0 : Celcius (default). */
|
||||
|
||||
|
||||
//--------------------------------- MEMS ------------------------------------
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
V12=0,
|
||||
V3=1,
|
||||
V6=2,
|
||||
V9=3
|
||||
} Rotate_H12_V_Match_TypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
s16 OutX ;
|
||||
s16 OutX_F4 ;
|
||||
s16 OutX_F16 ;
|
||||
s32 OutX_F64 ;
|
||||
s32 OutX_F256 ;
|
||||
s16 OutY ;
|
||||
s16 OutY_F4 ;
|
||||
s16 OutY_F16 ;
|
||||
s32 OutY_F64 ;
|
||||
s32 OutY_F256 ;
|
||||
s16 OutZ ;
|
||||
s16 OutZ_F4 ;
|
||||
s16 OutZ_F16 ;
|
||||
s32 OutZ_F64 ;
|
||||
s32 OutZ_F256 ;
|
||||
s16 Shocked ;
|
||||
s16 RELATIVE_X ;
|
||||
s16 RELATIVE_Y ;
|
||||
s16 DoubleClick ;
|
||||
} tMEMS_Info;
|
||||
|
||||
extern tMEMS_Info MEMS_Info;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
void MEMS_Init(void);
|
||||
void MEMS_Handler(void);
|
||||
void MEMS_GetPosition(s16 * pX, s16* pY);
|
||||
void MEMS_SetNeutral( void );
|
||||
void MEMS_GetRotation(Rotate_H12_V_Match_TypeDef * H12);
|
||||
tMEMS_Info* MEMS_GetInfo (void);
|
||||
u8 MEMS_ReadID(void);
|
||||
|
||||
//---------------------------------- LED -------------------------------------
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
enum LED_mode { LED_UNDEF = -1, LED_OFF = 0, LED_ON = 1, LED_BLINKING_LF = 2, LED_BLINKING_HF = 3 };
|
||||
enum LED_id { LED_GREEN = 0, LED_RED = 1};
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
void LED_Init (void);
|
||||
void LED_Handler_hw ( enum LED_id id );
|
||||
void LED_Handler ( void );
|
||||
void LED_Set ( enum LED_id id, enum LED_mode mode );
|
||||
|
||||
//-------------------------------- ADC --------------------------------------
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
void ADConverter_Init (void);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//-------------------------------- SHUTDOWN ---------------------------------
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
void SHUTDOWN_Action (void);
|
||||
|
||||
//-------------------------------- BUTTON -----------------------------------
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
enum BUTTON_mode { BUTTON_DISABLED = -1, BUTTON_ONOFF = 0,
|
||||
BUTTON_ONOFF_FORMAIN = 1, BUTTON_WITHCLICK = 2 };
|
||||
enum BUTTON_state { BUTTON_UNDEF = -1, BUTTON_RELEASED = 0, BUTTON_PUSHED = 1,
|
||||
BUTTON_PUSHED_FORMAIN = 2 , BUTTON_CLICK = 3, BUTTON_DBLCLICK = 4 };
|
||||
|
||||
/* Exported functions -------------------------------------------------------*/
|
||||
void BUTTON_Init (void);
|
||||
void BUTTON_Handler(void);
|
||||
enum BUTTON_state BUTTON_GetState();
|
||||
void BUTTON_SetMode( enum BUTTON_mode mode);
|
||||
enum BUTTON_mode BUTTON_GetMode ( void ) ;
|
||||
void BUTTON_WaitForRelease();
|
||||
|
||||
//-------------------------------- POINTER ----------------------------------
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
enum POINTER_mode { POINTER_UNDEF = -1, POINTER_OFF = 0, POINTER_ON = 1, POINTER_MENU = 2, POINTER_APPLICATION = 3, POINTER_RESTORE_LESS = 4 };
|
||||
enum POINTER_state { POINTER_S_UNDEF = -1, POINTER_S_DISABLED = 0, POINTER_S_ENABLED = 1 };
|
||||
|
||||
/* Exported defines ----------------------------------------------------------*/
|
||||
#define POINTER_WIDTH 7
|
||||
|
||||
typedef struct
|
||||
{
|
||||
s16 xPos ;
|
||||
s16 yPos ;
|
||||
s16 shift_PosX ;
|
||||
s16 shift_PosY ;
|
||||
s16 X_PosMin ;
|
||||
s16 Y_PosMin ;
|
||||
s16 X_PosMax ;
|
||||
s16 Y_PosMax ;
|
||||
} tPointer_Info;
|
||||
|
||||
extern tPointer_Info POINTER_Info ;
|
||||
|
||||
/* Exported vars -------------------------------------------------------------*/
|
||||
extern unsigned char *BallPointerBmpSize;
|
||||
extern unsigned char BallPointerBmp [POINTER_WIDTH], *CurrentPointerBmp,*CurrentPointerSize;
|
||||
extern u16 CurrentPointerColor;
|
||||
extern u16 BallColor;
|
||||
extern s16 POINTER_X_PosMin;
|
||||
extern s16 POINTER_Y_PosMin;
|
||||
extern s16 POINTER_X_PosMax;
|
||||
extern s16 POINTER_Y_PosMax;
|
||||
extern unsigned char PointerAreaStore [2*POINTER_WIDTH*POINTER_WIDTH];
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
extern void POINTER_Init ( void ) ;
|
||||
void POINTER_Handler(void);
|
||||
u16 POINTER_GetCurrentAngleStart ( void );
|
||||
void POINTER_SetCurrentAngleStart ( u16 );
|
||||
u16 POINTER_GetCurrentSpeedOnAngle ( void );
|
||||
void POINTER_SetCurrentSpeedOnAngle ( u16 newspeed );
|
||||
void POINTER_SetMode( enum POINTER_mode mode);
|
||||
void POINTER_SetCurrentPointer( unsigned char width, unsigned char height, unsigned char *bmp);
|
||||
enum POINTER_state POINTER_GetState(void);
|
||||
void POINTER_Draw (u8 Line, u8 Column, u8 Width, u8 Height, u8 *Bmp);
|
||||
void POINTER_SetRect ( s16 x, s16 y, s16 width, s16 height ); //Restrict the move of the pointer to a rectangle
|
||||
void POINTER_SetRectScreen ( void ); //Remove any space restriction for the pointer moves.
|
||||
void POINTER_Save (u8 Line, u8 Column, u8 Width, u8 Height);
|
||||
void POINTER_Restore (u8 Line, u8 Column, u8 Width, u8 Height);
|
||||
u16 POINTER_GetPos(void); //Return the poistion of the cursor (x=lower byte, y = upperbyte)
|
||||
void POINTER_SetPos ( u16 x, u16 y );
|
||||
typedef void (*tAppPtrMgr) ( int , int );
|
||||
void POINTER_SetApplication_Pointer_Mgr( tAppPtrMgr mgr );
|
||||
tPointer_Info* POINTER_GetInfo ( void );
|
||||
u16 POINTER_GetColor ( void ) ;
|
||||
void POINTER_SetColor ( u16 color );
|
||||
enum POINTER_mode POINTER_GetMode( void );
|
||||
void POINTER_SetCurrentAreaStore ( u8 *ptr );
|
||||
void LCD_SetRotateScreen ( u8 RotateScreen);
|
||||
u8 LCD_GetRotateScreen ();
|
||||
void LCD_SetScreenOrientation (Rotate_H12_V_Match_TypeDef ScreenOrientation);
|
||||
Rotate_H12_V_Match_TypeDef LCD_GetScreenOrientation ();
|
||||
|
||||
//---------------------------------- LCD -----------------------------------
|
||||
|
||||
/* Exported defines ----------------------------------------------------------*/
|
||||
//RGB is 16-bit coded as G2G1G0B4 B3B2B1B0 R4R3R2R1 R0G5G4G3
|
||||
#define RGB_MAKE(xR,xG,xB) ( ( (xG&0x07)<<13 ) + ( (xG)>>5 ) + \
|
||||
( ((xB)>>3) << 8 ) + \
|
||||
( ((xR)>>3) << 3 ) )
|
||||
#define RGB_RED 0x00F8
|
||||
#define RGB_BLACK 0x0000
|
||||
#define RGB_WHITE 0xffff
|
||||
#define RGB_BLUE 0x1F00
|
||||
#define RGB_GREEN 0xE007
|
||||
#define RGB_YELLOW (RGB_GREEN|RGB_RED)
|
||||
#define RGB_MAGENTA (RGB_BLUE|RGB_RED)
|
||||
#define RGB_LIGHTBLUE (RGB_BLUE|RGB_GREEN)
|
||||
#define RGB_ORANGE (RGB_RED | 0xE001) //green/2 + red
|
||||
#define RGB_PINK (RGB_MAGENTA | 0xE001) //green/2 + magenta
|
||||
|
||||
// SCREEN Infos
|
||||
#define SCREEN_WIDTH 128
|
||||
#define SCREEN_HEIGHT 128
|
||||
#define CHIP_SCREEN_WIDTH 132
|
||||
#define CHIP_SCREEN_HEIGHT 132
|
||||
|
||||
// Characters Infos
|
||||
#define CHAR_WIDTH 7
|
||||
#define CHAR_HEIGHT 14
|
||||
|
||||
// PWM rates.
|
||||
#define BACKLIGHTMIN 0x1000 /*!< Minimal PWM rate. */
|
||||
#define DEFAULT_CCR_BACKLIGHTSTART 0x8000 /*!< Default PWM rate. */
|
||||
|
||||
/* Exported vars -------------------------------------------------------------*/
|
||||
extern Rotate_H12_V_Match_TypeDef Screen_Orientation;
|
||||
extern int rotate_screen;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
void LCD_Init(void);
|
||||
void LCD_Handler(void);
|
||||
void LCD_SetRect_For_Cmd( s16 x, s16 y, s16 width, s16 height );
|
||||
u16 LCD_GetPixel( u8 x, u8 y );
|
||||
void LCD_DrawPixel( u8 x, u8 y, u16 Pixel );
|
||||
void LCD_SendLCDCmd( u8 Cmd );
|
||||
void LCD_SendLCDData( u8 Data );
|
||||
u32 LCD_ReadLCDData( void );
|
||||
void LCD_FillRect( u16 x, u16 y, u16 width, u16 height, u16 color );
|
||||
void LCD_DrawRect( u16 x, u16 y, u16 width, u16 height, u16 color );
|
||||
void LCD_DisplayChar( u8 x, u8 y, u8 Ascii, u16 TextColor, u16 BGndColor, u16 CharMagniCoeff );
|
||||
void LCD_RectRead( u16 x, u16 y, u16 width, u16 height, u8* bmp );
|
||||
void LCD_SetBackLight (u32 newBacklightStart);
|
||||
u32 LCD_GetBackLight ( void );
|
||||
void LCD_SetBackLightOff( void );
|
||||
void LCD_SetBackLightOn( void );
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
//---------------------------------- DRAW ----------------------------------
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
void DRAW_Init(void);
|
||||
void DRAW_Clear(void);
|
||||
void DRAW_Handler(void);
|
||||
void DRAW_SetDefaultColor (void);
|
||||
void DRAW_SetImage(const u16 *imageptr, u8 x, u8 y, u8 width, u8 height);
|
||||
void DRAW_SetImageBW(const u8 *imageptr, u8 x, u8 y, u8 width, u8 height);
|
||||
void DRAW_SetLogoBW(void);
|
||||
void DRAW_DisplayVbat(u8 x, u8 y);
|
||||
void DRAW_DisplayTime(u8 x, u8 y);
|
||||
void DRAW_DisplayTemp(u8 x, u8 y);
|
||||
void DRAW_DisplayString( u8 x, u8 y, const u8 *ptr, u8 len );
|
||||
void DRAW_DisplayStringInverted( u8 x, u8 y, const u8 *ptr, u8 len );
|
||||
u16 DRAW_GetCharMagniCoeff(void);
|
||||
void DRAW_SetCharMagniCoeff(u16 Coeff);
|
||||
u16 DRAW_GetTextColor(void);
|
||||
void DRAW_SetTextColor(u16 Color);
|
||||
u16 DRAW_GetBGndColor(void);
|
||||
void DRAW_SetBGndColor(u16 Color);
|
||||
void DRAW_Batt( void );
|
||||
void DRAW_Line (s16 x1, s16 y1, s16 x2, s16 y2, u16 color );
|
||||
|
||||
/* Exported vars -------------------------------------------------------------*/
|
||||
extern int fDisplayTime;
|
||||
|
||||
|
||||
//-------------------------------- BUZZER -----------------------------------
|
||||
|
||||
/* Exported defines ----------------------------------------------------------*/
|
||||
#define BUZZER_BEEP BUZZER_SHORTBEEP
|
||||
|
||||
/* Exported type def ---------------------------------------------------------*/
|
||||
enum BUZZER_mode { BUZZER_UNDEF = -1, BUZZER_OFF = 0, BUZZER_ON = 1,
|
||||
BUZZER_SHORTBEEP = 2, BUZZER_LONGBEEP = 3, BUZZER_PLAYMUSIC = 4 };
|
||||
|
||||
/* Exported type functions ---------------------------------------------------*/
|
||||
void BUZZER_Init(void);
|
||||
void BUZZER_Handler(void);
|
||||
void BUZZER_SetMode( enum BUZZER_mode mode);
|
||||
enum BUZZER_mode BUZZER_GetMode( void );
|
||||
void BUZZER_PlayMusic (const u8 *melody );
|
||||
|
||||
//--------------------------------- MENU -----------------------------------
|
||||
|
||||
/* Exported defines ----------------------------------------------------------*/
|
||||
#define MENU_MAXITEM 6
|
||||
#define APP_VOID ((tMenuItem *)(-1))
|
||||
#define MAX_APP_MENU_SIZE 10
|
||||
#define MAXAPP 64
|
||||
#define MAX_MENUAPP_SIZE 3
|
||||
#define REMOVE_MENU 0x01
|
||||
#define APP_MENU 0x02
|
||||
|
||||
enum MENU_code { MENU_LEAVE = 0, MENU_CONTINUE = 1, MENU_REFRESH = 2,
|
||||
MENU_CHANGE = 3, MENU_CONTINUE_COMMAND = 4};
|
||||
|
||||
/* Exported type def ---------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
const char *Text;
|
||||
enum MENU_code (*Fct_Init) ( void );
|
||||
enum MENU_code (*Fct_Manage)( void );
|
||||
int fMenuFlag;
|
||||
} tMenuItem;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned fdispTitle : 1;
|
||||
const char *Title;
|
||||
int NbItems;
|
||||
int LgMax;
|
||||
int XPos, YPos;
|
||||
int XSize, YSize;
|
||||
unsigned int SelectedItem;
|
||||
tMenuItem Items[MENU_MAXITEM];
|
||||
} tMenu;
|
||||
|
||||
/* Exported vars -------------------------------------------------------------*/
|
||||
extern tMenu MainMenu, *CurrentMenu;
|
||||
extern tMenuItem *CurrentCommand;
|
||||
extern int BGndColor_Menu;
|
||||
extern int TextColor_Menu;
|
||||
|
||||
/* Exported type functions ---------------------------------------------------*/
|
||||
enum MENU_code fColor ( void ) ;
|
||||
void MENU_Set ( tMenu *mptr );
|
||||
void MENU_Handler ( void ) ;
|
||||
extern enum MENU_code MENU_Quit ( void );
|
||||
void MENU_Remove ( void ) ;
|
||||
void MENU_Question ( char *str, int *answer );
|
||||
void MENU_Print ( char *str );
|
||||
enum MENU_code MENU_SetLevel_Ini( void );
|
||||
enum MENU_code MENU_SetLevel_Mgr( u32 *value, u32 value_range [] ) ;
|
||||
void MENU_ClearCurrentCommand( void );
|
||||
void MENU_SetLevelTitle(u8* title);
|
||||
void MENU_SetTextColor ( int TextColor );
|
||||
int MENU_GetTextColor ( void );
|
||||
void MENU_SetBGndColor ( int BGndColor );
|
||||
int MENU_GetBGndColor ( void );
|
||||
extern enum MENU_code fQuit ( void ) ;
|
||||
void MENU_ClearCurrentMenu(void);
|
||||
|
||||
//-------------------------------- BACKLIGHT --------------------------------
|
||||
|
||||
/* Exported type functions ---------------------------------------------------*/
|
||||
void BackLight_Configuration (void);
|
||||
void ManageBackLight (void);
|
||||
void BackLight_Change (void);
|
||||
|
||||
//-------------------------------- RTC --------------------------------------
|
||||
|
||||
/* Exported type functions ---------------------------------------------------*/
|
||||
void RTC_Init(void);
|
||||
void RTC_SetTime (u32 THH, u32 TMM, u32 TSS);
|
||||
void RTC_GetTime (u32 * THH, u32 * TMM, u32 * TSS);
|
||||
void RTC_DisplayTime ( void );
|
||||
|
||||
//Backup registers
|
||||
#define BKP_SYS1 1
|
||||
#define BKP_SYS2 2
|
||||
#define BKP_SYS3 3
|
||||
#define BKP_SYS4 4
|
||||
#define BKP_SYS5 5
|
||||
#define BKP_SYS6 6
|
||||
#define BKP_USER1 7
|
||||
#define BKP_USER2 8
|
||||
#define BKP_USER3 9
|
||||
#define BKP_USER4 10
|
||||
|
||||
#define BKP_PLL (BKP_SYS2)
|
||||
#define BKP_BKLIGHT (BKP_SYS3)
|
||||
|
||||
//--------------------------------- Application --------------------------------
|
||||
void (*Application_Pointer_Mgr) ( int sposX, int sposY);
|
||||
|
||||
#endif /*__CIRCLE_H */
|
||||
679
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/circle_api.h
Normal file
679
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/circle_api.h
Normal file
File diff suppressed because it is too large
Load Diff
217
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/crt0_STM32x.c
Normal file
217
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/crt0_STM32x.c
Normal file
@@ -0,0 +1,217 @@
|
||||
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
|
||||
* File Name : stm32f10x_vector.c
|
||||
* Author : MCD Tools Team
|
||||
* Date First Issued : 05/14/2007
|
||||
* Description : This file contains the vector table for STM32F10x.
|
||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
||||
* priority is Privileged, and the Stack is set to Main.
|
||||
********************************************************************************
|
||||
* History:
|
||||
* 05/14/2007: V0.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.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Includes ----------------------------------------------------------------------*/
|
||||
|
||||
void NMIException(void);
|
||||
void HardFaultException(void);
|
||||
void MemManageException(void);
|
||||
void BusFaultException(void);
|
||||
void UsageFaultException(void);
|
||||
void DebugMonitor(void);
|
||||
void SVCHandler(void);
|
||||
void PendSVC(void);
|
||||
void SysTickHandler(void);
|
||||
void WWDG_IRQHandler(void);
|
||||
void PVD_IRQHandler(void);
|
||||
void TAMPER_IRQHandler(void);
|
||||
void RTC_IRQHandler(void);
|
||||
void FLASH_IRQHandler(void);
|
||||
void RCC_IRQHandler(void);
|
||||
void EXTI0_IRQHandler(void);
|
||||
void EXTI1_IRQHandler(void);
|
||||
void EXTI2_IRQHandler(void);
|
||||
void EXTI3_IRQHandler(void);
|
||||
void EXTI4_IRQHandler(void);
|
||||
void DMAChannel1_IRQHandler(void);
|
||||
void DMAChannel2_IRQHandler(void);
|
||||
void DMAChannel3_IRQHandler(void);
|
||||
void DMAChannel4_IRQHandler(void);
|
||||
void DMAChannel5_IRQHandler(void);
|
||||
void DMAChannel6_IRQHandler(void);
|
||||
void DMAChannel7_IRQHandler(void);
|
||||
void ADC_IRQHandler(void);
|
||||
void USB_HP_CAN_TX_IRQHandler(void);
|
||||
void USB_LP_CAN_RX0_IRQHandler(void);
|
||||
void CAN_RX1_IRQHandler(void);
|
||||
void CAN_SCE_IRQHandler(void);
|
||||
void EXTI9_5_IRQHandler(void);
|
||||
void TIM1_BRK_IRQHandler(void);
|
||||
void TIM1_UP_IRQHandler(void);
|
||||
void TIM1_TRG_COM_IRQHandler(void);
|
||||
void TIM1_CC_IRQHandler(void);
|
||||
void TIM2_IRQHandler(void);
|
||||
void TIM3_IRQHandler(void);
|
||||
void TIM4_IRQHandler(void);
|
||||
void I2C1_EV_IRQHandler(void);
|
||||
void I2C1_ER_IRQHandler(void);
|
||||
void I2C2_EV_IRQHandler(void);
|
||||
void I2C2_ER_IRQHandler(void);
|
||||
void SPI1_IRQHandler(void);
|
||||
void SPI2_IRQHandler(void);
|
||||
void USART1_IRQHandler(void);
|
||||
void USART2_IRQHandler(void);
|
||||
void USART3_IRQHandler(void);
|
||||
void EXTI15_10_IRQHandler(void);
|
||||
void RTCAlarm_IRQHandler(void);
|
||||
void USBWakeUp_IRQHandler(void);
|
||||
|
||||
|
||||
/* Exported types --------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
extern unsigned long _etext;
|
||||
extern unsigned long _sidata; /* start address for the initialization values of the .data section. defined in linker script */
|
||||
extern unsigned long _sdata; /* start address for the .data section. defined in linker script */
|
||||
extern unsigned long _edata; /* end address for the .data section. defined in linker script */
|
||||
|
||||
extern unsigned long _sbss; /* start address for the .bss section. defined in linker script */
|
||||
extern unsigned long _ebss; /* end address for the .bss section. defined in linker script */
|
||||
|
||||
extern void _estack; /* init value for the stack pointer. defined in linker script */
|
||||
|
||||
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* function prototypes ------------------------------------------------------*/
|
||||
void Reset_Handler(void) __attribute__((__interrupt__));
|
||||
extern int main(void);
|
||||
extern void xPortPendSVHandler(void);
|
||||
extern void xPortSysTickHandler(void);
|
||||
extern void vTimer2IntHandler( void );
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
||||
* must be placed on this to ensure that it ends up at physical address
|
||||
* 0x0000.0000.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
__attribute__ ((section(".isr_vector")))
|
||||
void (* const g_pfnVectors[])(void) =
|
||||
{
|
||||
&_estack, // The initial stack pointer
|
||||
Reset_Handler, // The reset handler
|
||||
NMIException,
|
||||
HardFaultException,
|
||||
MemManageException,
|
||||
BusFaultException,
|
||||
UsageFaultException,
|
||||
0, 0, 0, 0, /* Reserved */
|
||||
SVCHandler,
|
||||
DebugMonitor,
|
||||
0, /* Reserved */
|
||||
xPortPendSVHandler,
|
||||
xPortSysTickHandler,
|
||||
WWDG_IRQHandler,
|
||||
PVD_IRQHandler,
|
||||
TAMPER_IRQHandler,
|
||||
RTC_IRQHandler,
|
||||
FLASH_IRQHandler,
|
||||
RCC_IRQHandler,
|
||||
EXTI0_IRQHandler,
|
||||
EXTI1_IRQHandler,
|
||||
EXTI2_IRQHandler,
|
||||
EXTI3_IRQHandler,
|
||||
EXTI4_IRQHandler,
|
||||
DMAChannel1_IRQHandler,
|
||||
DMAChannel2_IRQHandler,
|
||||
DMAChannel3_IRQHandler,
|
||||
DMAChannel4_IRQHandler,
|
||||
DMAChannel5_IRQHandler,
|
||||
DMAChannel6_IRQHandler,
|
||||
DMAChannel7_IRQHandler,
|
||||
ADC_IRQHandler,
|
||||
USB_HP_CAN_TX_IRQHandler,
|
||||
USB_LP_CAN_RX0_IRQHandler,
|
||||
CAN_RX1_IRQHandler,
|
||||
CAN_SCE_IRQHandler,
|
||||
EXTI9_5_IRQHandler,
|
||||
TIM1_BRK_IRQHandler,
|
||||
TIM1_UP_IRQHandler,
|
||||
TIM1_TRG_COM_IRQHandler,
|
||||
TIM1_CC_IRQHandler,
|
||||
vTimer2IntHandler,
|
||||
TIM3_IRQHandler,
|
||||
TIM4_IRQHandler,
|
||||
I2C1_EV_IRQHandler,
|
||||
I2C1_ER_IRQHandler,
|
||||
I2C2_EV_IRQHandler,
|
||||
I2C2_ER_IRQHandler,
|
||||
SPI1_IRQHandler,
|
||||
SPI2_IRQHandler,
|
||||
USART1_IRQHandler,
|
||||
USART2_IRQHandler,
|
||||
USART3_IRQHandler,
|
||||
EXTI15_10_IRQHandler,
|
||||
RTCAlarm_IRQHandler,
|
||||
USBWakeUp_IRQHandler,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
(unsigned long)0xF108F85F //this is a workaround for boot in RAM mode.
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Reset_Handler
|
||||
* Description : This is the code that gets called when the processor first starts execution
|
||||
* following a reset event. Only the absolutely necessary set is performed,
|
||||
* after which the application supplied main() routine is called.
|
||||
* Input :
|
||||
* Output :
|
||||
* Return :
|
||||
*******************************************************************************/
|
||||
void Reset_Handler(void)
|
||||
{
|
||||
unsigned long *pulSrc, *pulDest;
|
||||
|
||||
//
|
||||
// Copy the data segment initializers from flash to SRAM.
|
||||
//
|
||||
pulSrc = &_sidata;
|
||||
for(pulDest = &_sdata; pulDest < &_edata; )
|
||||
{
|
||||
*(pulDest++) = *(pulSrc++);
|
||||
}
|
||||
|
||||
//
|
||||
// Zero fill the bss segment.
|
||||
//
|
||||
for(pulDest = &_sbss; pulDest < &_ebss; )
|
||||
{
|
||||
*(pulDest++) = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Call the application's entry point.
|
||||
//
|
||||
main();
|
||||
}
|
||||
|
||||
|
||||
/********************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/
|
||||
|
||||
|
||||
545
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/draw.c
Normal file
545
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/draw.c
Normal file
File diff suppressed because it is too large
Load Diff
1189
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/lcd.c
Normal file
1189
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/lcd.c
Normal file
File diff suppressed because it is too large
Load Diff
154
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/lcd.h
Normal file
154
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/lcd.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/********************* (C) COPYRIGHT 2007 RAISONANCE S.A.S. *******************/
|
||||
/**
|
||||
*
|
||||
* @file lcd.h
|
||||
* @brief The header file for ST7637 driver.
|
||||
* @author IB
|
||||
* @date 07/2007
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __LCD_H
|
||||
#define __LCD_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f10x_lib.h"
|
||||
|
||||
/* Type def -----------------------------------------------------------------*/
|
||||
|
||||
/* Data lines configuration mode */
|
||||
typedef enum
|
||||
{
|
||||
Input,
|
||||
Output
|
||||
} DataConfigMode_TypeDef;
|
||||
|
||||
/* Constants -----------------------------------------------------------------*/
|
||||
|
||||
/* LCD Control pins */
|
||||
#define CtrlPin_RS GPIO_Pin_8
|
||||
#define CtrlPin_RD GPIO_Pin_9
|
||||
#define CtrlPin_WR GPIO_Pin_10
|
||||
#define CtrlPin_RST GPIO_Pin_12
|
||||
#define LCD_CTRL_PINS (CtrlPin_RS|CtrlPin_RD|CtrlPin_WR|CtrlPin_RST)
|
||||
#define GPIOx_CTRL_LCD GPIOC
|
||||
#define GPIO_LCD_CTRL_PERIPH RCC_APB2Periph_GPIOC
|
||||
|
||||
#define CtrlPin_CS GPIO_Pin_2
|
||||
#define GPIOx_CS_LCD GPIOD
|
||||
#define GPIO_LCD_CS_PERIPH RCC_APB2Periph_GPIOD
|
||||
|
||||
#define LCD_D0 GPIO_Pin_0
|
||||
#define LCD_D1 GPIO_Pin_1
|
||||
#define LCD_D2 GPIO_Pin_2
|
||||
#define LCD_D3 GPIO_Pin_3
|
||||
#define LCD_D4 GPIO_Pin_4
|
||||
#define LCD_D5 GPIO_Pin_5
|
||||
#define LCD_D6 GPIO_Pin_6
|
||||
#define LCD_D7 GPIO_Pin_7
|
||||
#define LCD_DATA_PINS (LCD_D0|LCD_D1|LCD_D2|LCD_D3|LCD_D4|LCD_D5|LCD_D6|LCD_D7)
|
||||
#define GPIOx_D_LCD GPIOC
|
||||
#define GPIO_LCD_D_PERIPH RCC_APB2Periph_GPIOC
|
||||
|
||||
/* LCD Commands */
|
||||
#define DISPLAY_ON 0xAF
|
||||
#define DISPLAY_OFF 0xAE
|
||||
#define START_LINE 0xC0
|
||||
#define START_COLUMN 0x00
|
||||
#define CLOCKWISE_OUTPUT 0xA0
|
||||
#define DYNAMIC_DRIVE 0xA4
|
||||
#define DUTY_CYCLE 0xA9
|
||||
#define READ_MODIFY_WRITE_OFF 0xEE
|
||||
#define SOFTWARE_RESET 0xE2
|
||||
|
||||
#define ST7637_NOP 0x00
|
||||
#define ST7637_SWRESET 0x01
|
||||
#define ST7637_RDDID 0x04
|
||||
#define ST7637_RDDST 0x09
|
||||
#define ST7637_RDDPM 0x0A
|
||||
#define ST7637_RDDMADCTR 0x0B
|
||||
#define ST7637_RDDCOLMOD 0x0C
|
||||
#define ST7637_RDDIM 0x0D
|
||||
#define ST7637_RDDSM 0x0E
|
||||
#define ST7637_RDDSDR 0x0F
|
||||
|
||||
#define ST7637_SLPIN 0x10
|
||||
#define ST7637_SLPOUT 0x11
|
||||
#define ST7637_PTLON 0x12
|
||||
#define ST7637_NORON 0x13
|
||||
|
||||
#define ST7637_INVOFF 0x20
|
||||
#define ST7637_INVON 0x21
|
||||
#define ST7637_APOFF 0x22
|
||||
#define ST7637_APON 0x23
|
||||
#define ST7637_WRCNTR 0x25
|
||||
#define ST7637_DISPOFF 0x28
|
||||
#define ST7637_DISPON 0x29
|
||||
#define ST7637_CASET 0x2A
|
||||
#define ST7637_RASET 0x2B
|
||||
#define ST7637_RAMWR 0x2C
|
||||
#define ST7637_RGBSET 0x2D
|
||||
#define ST7637_RAMRD 0x2E
|
||||
|
||||
#define ST7637_PTLAR 0x30
|
||||
#define ST7637_SCRLAR 0x33
|
||||
#define ST7637_TEOFF 0x34
|
||||
#define ST7637_TEON 0x35
|
||||
#define ST7637_MADCTR 0x36
|
||||
#define ST7637_VSCSAD 0x37
|
||||
#define ST7637_IDMOFF 0x38
|
||||
#define ST7637_IDMON 0x39
|
||||
#define ST7637_COLMOD 0x3A
|
||||
|
||||
#define ST7637_RDID1 0xDA
|
||||
#define ST7637_RDID2 0xDB
|
||||
#define ST7637_RDID3 0xDC
|
||||
|
||||
#define ST7637_DUTYSET 0xB0
|
||||
#define ST7637_FIRSTCOM 0xB1
|
||||
#define ST7637_OSCDIV 0xB3
|
||||
#define ST7637_PTLMOD 0xB4
|
||||
#define ST7637_NLINVSET 0xB5
|
||||
#define ST7637_COMSCANDIR 0xB7
|
||||
#define ST7637_RMWIN 0xB8
|
||||
#define ST7637_RMWOUT 0xB9
|
||||
|
||||
#define ST7637_VOPSET 0xC0
|
||||
#define ST7637_VOPOFSETINC 0xC1
|
||||
#define ST7637_VOPOFSETDEC 0xC2
|
||||
#define ST7637_BIASSEL 0xC3
|
||||
#define ST7637_BSTBMPXSEL 0xC4
|
||||
#define ST7637_BSTEFFSEL 0xC5
|
||||
#define ST7637_VOPOFFSET 0xC7
|
||||
#define ST7637_VGSORCSEL 0xCB
|
||||
|
||||
#define ST7637_ID1SET 0xCC
|
||||
#define ST7637_ID2SET 0xCD
|
||||
#define ST7637_ID3SET 0xCE
|
||||
|
||||
#define ST7637_ANASET 0xD0
|
||||
#define ST7637_AUTOLOADSET 0xD7
|
||||
#define ST7637_RDTSTSTATUS 0xDE
|
||||
|
||||
#define ST7637_EPCTIN 0xE0
|
||||
#define ST7637_EPCTOUT 0xE1
|
||||
#define ST7637_EPMWR 0xE2
|
||||
#define ST7637_EPMRD 0xE3
|
||||
#define ST7637_MTPSEL 0xE4
|
||||
#define ST7637_ROMSET 0xE5
|
||||
#define ST7637_HPMSET 0xEB
|
||||
|
||||
#define ST7637_FRMSEL 0xF0
|
||||
#define ST7637_FRM8SEL 0xF1
|
||||
#define ST7637_TMPRNG 0xF2
|
||||
#define ST7637_TMPHYS 0xF3
|
||||
#define ST7637_TEMPSEL 0xF4
|
||||
#define ST7637_THYS 0xF7
|
||||
#define ST7637_FRAMESET 0xF9
|
||||
|
||||
#define ST7637_MAXCOL 0x83
|
||||
#define ST7637_MAXPAG 0x83
|
||||
|
||||
#endif /*__LCD_H */
|
||||
210
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/led.c
Normal file
210
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/led.c
Normal file
@@ -0,0 +1,210 @@
|
||||
/********************* (C) COPYRIGHT 2007 RAISONANCE S.A.S. *******************/
|
||||
/**
|
||||
*
|
||||
* @file led.c
|
||||
* @brief LED management.
|
||||
* @author IB
|
||||
* @date 07/2007
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "circle.h"
|
||||
|
||||
/// @cond Internal
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
int GreenLED_Counter = 0;
|
||||
int RedLED_Counter = 0;
|
||||
enum LED_mode GreenLED_mode = LED_UNDEF;
|
||||
enum LED_mode RedLED_mode = LED_UNDEF;
|
||||
enum LED_mode GreenLED_newmode = LED_OFF;
|
||||
enum LED_mode RedLED_newmode = LED_OFF;
|
||||
const int HalfPeriod_LF = 200;
|
||||
const int HalfPeriod_HF = 50;
|
||||
const int Period_LF = 200 * 2;
|
||||
const int Period_HF = 50 * 2;
|
||||
|
||||
/* Public functions for CircleOS ---------------------------------------------*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* LED_Init
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Initialization of the GPIOs for the LEDs
|
||||
*
|
||||
* @note Is called by CircleOS startup.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void LED_Init( void )
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
/* Enable LED GPIO clock */
|
||||
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE );
|
||||
|
||||
/* Configure LED pins as output push-pull */
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 ;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
|
||||
GPIO_Init( GPIOB, &GPIO_InitStructure );
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* LED_Handler
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Called by the CircleOS scheduler to manage the states of the LEDs.
|
||||
* LEDs may be on, off or blinking according to their state.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void LED_Handler( void )
|
||||
{
|
||||
LED_Handler_hw(LED_GREEN);
|
||||
LED_Handler_hw(LED_RED);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* LED_Handler
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Called by the CircleOS scheduler to manage the states of the LEDs.
|
||||
* LEDs may be on, off or blinking according to their state.
|
||||
*
|
||||
* @param[in] id A LED_id indicating the LED to take care of.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void LED_Handler_hw( enum LED_id id )
|
||||
{
|
||||
int counter;
|
||||
enum LED_mode mode;
|
||||
|
||||
// Choose the right LED parameters.
|
||||
if( id == LED_GREEN )
|
||||
{
|
||||
counter = GreenLED_Counter;
|
||||
mode = GreenLED_newmode;
|
||||
}
|
||||
else
|
||||
{
|
||||
counter = RedLED_Counter;
|
||||
mode = RedLED_newmode;
|
||||
}
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case LED_OFF :
|
||||
case LED_ON :
|
||||
if( ( ( id == LED_GREEN ) && ( GreenLED_mode == mode ) ) ||
|
||||
( ( id == LED_RED ) && ( RedLED_mode == mode ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( id == LED_GREEN )
|
||||
{
|
||||
GPIO_WriteBit( GPIOB, GPIO_Pin_8, ( mode == LED_OFF ) ? Bit_RESET : Bit_SET );
|
||||
|
||||
GreenLED_mode = mode;
|
||||
}
|
||||
else if( id == LED_RED )
|
||||
{
|
||||
GPIO_WriteBit( GPIOB, GPIO_Pin_9, ( mode == LED_OFF ) ? Bit_RESET : Bit_SET );
|
||||
|
||||
RedLED_mode = mode;
|
||||
}
|
||||
|
||||
counter = -1;
|
||||
break;
|
||||
|
||||
case LED_BLINKING_HF :
|
||||
counter++;
|
||||
|
||||
if( counter == HalfPeriod_HF )
|
||||
{
|
||||
GPIO_WriteBit( GPIOB, ( id == LED_RED ) ? GPIO_Pin_9 : GPIO_Pin_8, Bit_SET );
|
||||
}
|
||||
else if( ( counter < 0 ) || ( counter >= Period_HF ) )
|
||||
{
|
||||
GPIO_WriteBit( GPIOB, ( id == LED_RED ) ? GPIO_Pin_9 : GPIO_Pin_8, Bit_RESET );
|
||||
|
||||
counter = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case LED_BLINKING_LF :
|
||||
counter++;
|
||||
|
||||
if( counter == HalfPeriod_LF )
|
||||
{
|
||||
GPIO_WriteBit( GPIOB, ( id == LED_RED ) ? GPIO_Pin_9 : GPIO_Pin_8, Bit_SET );
|
||||
}
|
||||
|
||||
else if( ( counter < 0 ) || ( counter >= Period_LF ) )
|
||||
{
|
||||
GPIO_WriteBit( GPIOB, ( id == LED_RED ) ? GPIO_Pin_9 : GPIO_Pin_8, Bit_RESET );
|
||||
|
||||
counter = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
if( id == LED_GREEN )
|
||||
{
|
||||
GreenLED_Counter = counter;
|
||||
GreenLED_mode = mode;
|
||||
}
|
||||
else
|
||||
{
|
||||
RedLED_Counter = counter;
|
||||
RedLED_mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
/// @endcond
|
||||
|
||||
/* Public functions ----------------------------------------------------------*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* LED_Set
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Set a specified LED in a specified mode.
|
||||
*
|
||||
* @param[in] id A LED_id specifying the LED to change the mode.
|
||||
* @param[in] mode A LED_mode describing the new LED mode.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void LED_Set( enum LED_id id, enum LED_mode mode )
|
||||
{
|
||||
if( id == LED_GREEN )
|
||||
{
|
||||
GreenLED_newmode = mode;
|
||||
}
|
||||
else if( id == LED_RED )
|
||||
{
|
||||
RedLED_newmode = mode;
|
||||
}
|
||||
}
|
||||
605
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/mems.c
Normal file
605
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/mems.c
Normal file
File diff suppressed because it is too large
Load Diff
901
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/pointer.c
Normal file
901
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/pointer.c
Normal file
File diff suppressed because it is too large
Load Diff
81
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/scheduler.h
Normal file
81
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/scheduler.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/********************* (C) COPYRIGHT 2007 RAISONANCE S.A.S. *******************/
|
||||
/**
|
||||
*
|
||||
* @file scheduler.h
|
||||
* @brief Header file for the SysTick interrupt handler of the CircleOS project.
|
||||
* @author FL
|
||||
* @author IB
|
||||
* @date 07/2007
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F10x_IT_H
|
||||
#define __STM32F10x_IT_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f10x_lib.h"
|
||||
|
||||
void NMIException( void );
|
||||
void HardFaultException( void );
|
||||
void MemManageException( void );
|
||||
void BusFaultException( void );
|
||||
void UsageFaultException( void );
|
||||
void DebugMonitor( void );
|
||||
void SVCHandler( void );
|
||||
void PendSVC( void );
|
||||
void SysTickHandler( void );
|
||||
void WWDG_IRQHandler( void );
|
||||
void PVD_IRQHandler( void );
|
||||
void TAMPER_IRQHandler( void );
|
||||
void RTC_IRQHandler( void );
|
||||
void FLASH_IRQHandler( void );
|
||||
void RCC_IRQHandler( void );
|
||||
void EXTI0_IRQHandler( void );
|
||||
void EXTI1_IRQHandler( void );
|
||||
void EXTI2_IRQHandler( void );
|
||||
void EXTI3_IRQHandler( void );
|
||||
void EXTI4_IRQHandler( void );
|
||||
void DMAChannel1_IRQHandler( void );
|
||||
void DMAChannel2_IRQHandler( void );
|
||||
void DMAChannel3_IRQHandler( void );
|
||||
void DMAChannel4_IRQHandler( void );
|
||||
void DMAChannel5_IRQHandler( void );
|
||||
void DMAChannel6_IRQHandler( void );
|
||||
void DMAChannel7_IRQHandler( void );
|
||||
void ADC_IRQHandler( void );
|
||||
void USB_HP_CAN_TX_IRQHandler( void );
|
||||
void USB_LP_CAN_RX0_IRQHandler( void );
|
||||
void CAN_RX1_IRQHandler( void );
|
||||
void CAN_SCE_IRQHandler( void );
|
||||
void EXTI9_5_IRQHandler( void );
|
||||
void TIM1_BRK_IRQHandler( void );
|
||||
void TIM1_UP_IRQHandler( void );
|
||||
void TIM1_TRG_CCUP_IRQHandler( void );
|
||||
void TIM1_CC_IRQHandler( void );
|
||||
void TIM2_IRQHandler( void );
|
||||
void TIM3_IRQHandler( void );
|
||||
void TIM4_IRQHandler( void );
|
||||
void I2C1_EV_IRQHandler( void );
|
||||
void I2C1_ER_IRQHandler( void );
|
||||
void I2C2_EV_IRQHandler( void );
|
||||
void I2C2_ER_IRQHandler( void );
|
||||
void SPI1_IRQHandler( void );
|
||||
void SPI2_IRQHandler( void );
|
||||
void USART1_IRQHandler( void );
|
||||
void USART2_IRQHandler( void );
|
||||
void USART3_IRQHandler( void );
|
||||
void EXTI15_10_IRQHandler( void );
|
||||
void RTCAlarm_IRQHandler( void );
|
||||
void USBWakeUp_IRQHandler( void );
|
||||
|
||||
//FL071107 Make the scheduler configurable. The handler are inserted into a list that could
|
||||
//be modified by the applications.
|
||||
typedef void (*tHandler) ( void );
|
||||
extern tHandler SchHandler [16+1];
|
||||
#define SCH_HDL_MAX ( sizeof SchHandler / sizeof (tHandler) )
|
||||
|
||||
|
||||
|
||||
#endif /* __STM32F10x_IT_H */
|
||||
217
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/stm32f10x_circle_it.c
Normal file
217
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/stm32f10x_circle_it.c
Normal file
@@ -0,0 +1,217 @@
|
||||
/********************* (C) COPYRIGHT 2007 RAISONANCE S.A.S. *******************/
|
||||
/**
|
||||
*
|
||||
* @file stm32f10x_circle_it.c
|
||||
* @brief Interrupt handler for the CircleOS project.
|
||||
* @author FL
|
||||
* @author IB
|
||||
* @date 07/2007
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "circle.h"
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern u16 CCR_Val;
|
||||
extern u16 Current_CCR_BackLightStart;
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* NMIException
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Handles the NMI exception.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void NMIException( void ) {}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* HardFaultException
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Handles the Hard Fault exception.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void HardFaultException( void )
|
||||
{
|
||||
#ifdef TIMING_ANALYSIS //to debug with a scope
|
||||
GPIO_WriteBit( GPIOA, GPIO_Pin_5, Bit_RESET );
|
||||
GPIO_WriteBit( GPIOA, GPIO_Pin_5, Bit_SET );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* MemManageException
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Handles the Memory Manage exception.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void MemManageException( void ) {}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* BusFaultException
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Handles the Bus Fault exception.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void BusFaultException( void ) {}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* UsageFaultException
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Handles the Usage Fault exception.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void UsageFaultException( void ) {}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* DebugMonitor
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Handles the Debug Monitor exception.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void DebugMonitor( void ) {}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* SVCHandler
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Handles the SVCall exception.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void SVCHandler( void ) {}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* PendSVC
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Handles the PendSVC exception.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void PendSVC( void ) {}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* DummyHandler
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Default handling for the IRQ-Exception
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void DummyHandler ( void ) {}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* TIM2_IRQHandler
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Handles the TIM2 global interrupt request.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void TIM2_IRQHandler( void )
|
||||
{
|
||||
#ifdef TIMING_ANALYSIS //to debug with a scope
|
||||
GPIO_WriteBit( GPIOA, GPIO_Pin_7, Bit_RESET );
|
||||
#endif
|
||||
|
||||
/* Clear TIM2 update interrupt */
|
||||
TIM_ClearITPendingBit( TIM2, TIM_IT_Update );
|
||||
|
||||
MEMS_Handler();
|
||||
|
||||
#ifdef TIMING_ANALYSIS //to debug with a scope
|
||||
GPIO_WriteBit( GPIOA, GPIO_Pin_7, Bit_SET );
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* TIM3_IRQHandler
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Handles the TIM3 global interrupt request.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void TIM3_IRQHandler( void )
|
||||
{
|
||||
u16 capture = 0;
|
||||
|
||||
if( TIM_GetITStatus( TIM3, TIM_IT_CC3 ) != RESET )
|
||||
{
|
||||
capture = TIM_GetCapture3( TIM3 );
|
||||
|
||||
TIM_SetCompare3( TIM3, capture + CCR_Val + 1 );
|
||||
TIM_ClearITPendingBit( TIM3, TIM_IT_CC3 );
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* TIM4_IRQHandler
|
||||
*
|
||||
*******************************************************************************/
|
||||
/**
|
||||
*
|
||||
* Handles the TIM4 global interrupt request.
|
||||
*
|
||||
**/
|
||||
/******************************************************************************/
|
||||
void TIM4_IRQHandler( void )
|
||||
{
|
||||
u16 BackLight_capture = 0;
|
||||
|
||||
if( TIM_GetITStatus( TIM4, TIM_IT_CC2 ) != RESET )
|
||||
{
|
||||
BackLight_capture = TIM_GetCapture2( TIM4 );
|
||||
|
||||
TIM_SetCompare2( TIM4, BackLight_capture + Current_CCR_BackLightStart + 1 );
|
||||
TIM_ClearITPendingBit( TIM4, TIM_IT_CC2 );
|
||||
}
|
||||
}
|
||||
|
||||
119
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/stm32f10x_conf.h
Normal file
119
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/stm32f10x_conf.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
|
||||
* File Name : stm32f10x_conf.h
|
||||
* Author : MCD Application Team
|
||||
* Date First Issued : 09/29/2006
|
||||
* Description : Library configuration file.
|
||||
********************************************************************************
|
||||
* History:
|
||||
* 02/05/2007: V0.1
|
||||
* 09/29/2006: V0.01
|
||||
********************************************************************************
|
||||
* 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 to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F10x_CONF_H
|
||||
#define __STM32F10x_CONF_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Comment the line below to compile the library in release mode */
|
||||
//#define DEBUG 0
|
||||
|
||||
/* Comment the line below to disable the specific peripheral inclusion */
|
||||
/************************************* ADC ************************************/
|
||||
//#define _ADC
|
||||
#define _ADC1
|
||||
#define _ADC2
|
||||
|
||||
/************************************* CAN ************************************/
|
||||
//#define _CAN
|
||||
|
||||
/************************************* DMA ************************************/
|
||||
//#define _DMA
|
||||
#define _DMA_Channel1
|
||||
#define _DMA_Channel2
|
||||
#define _DMA_Channel3
|
||||
#define _DMA_Channel4
|
||||
#define _DMA_Channel5
|
||||
#define _DMA_Channel6
|
||||
#define _DMA_Channel7
|
||||
|
||||
/************************************* EXTI ***********************************/
|
||||
//#define _EXTI
|
||||
|
||||
/************************************* GPIO ***********************************/
|
||||
#define _GPIO
|
||||
#define _GPIOA
|
||||
#define _GPIOB
|
||||
#define _GPIOC
|
||||
#define _GPIOD
|
||||
//#define _GPIOE
|
||||
#define _AFIO
|
||||
|
||||
/************************************* I2C ************************************/
|
||||
//#define _I2C
|
||||
//#define _I2C1
|
||||
//#define _I2C2
|
||||
|
||||
/************************************* IWDG ***********************************/
|
||||
//#define _IWDG
|
||||
|
||||
/************************************* NVIC ***********************************/
|
||||
#define _NVIC
|
||||
#define _SCB
|
||||
|
||||
/************************************* BKP ************************************/
|
||||
//#define _BKP
|
||||
|
||||
/************************************* PWR ************************************/
|
||||
//#define _PWR
|
||||
|
||||
/************************************* RCC ************************************/
|
||||
#define _RCC
|
||||
|
||||
/************************************* RTC ************************************/
|
||||
//#define _RTC
|
||||
|
||||
/************************************* SPI ************************************/
|
||||
#define _SPI
|
||||
//#define _SPI1
|
||||
#define _SPI2
|
||||
|
||||
/************************************* SysTick ********************************/
|
||||
#define _SysTick
|
||||
|
||||
/************************************* TIM1 ***********************************/
|
||||
//#define _TIM1
|
||||
|
||||
/************************************* TIM ************************************/
|
||||
#define _TIM
|
||||
#define _TIM2
|
||||
#define _TIM3
|
||||
#define _TIM4
|
||||
|
||||
/************************************* USART **********************************/
|
||||
//#define _USART
|
||||
//#define _USART1
|
||||
//#define _USART2
|
||||
//#define _USART3
|
||||
|
||||
/************************************* WWDG ***********************************/
|
||||
//#define _WWDG
|
||||
|
||||
/* In the following line adjust the value of External High Speed oscillator (HSE)
|
||||
used in your application */
|
||||
#define HSE_Value ((u32)12000000) /* Value of the External oscillator in Hz*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
#endif /* __STM32F10x_CONF_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/
|
||||
70
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/stm32f10x_it.h
Normal file
70
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/stm32f10x_it.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/********************* (C) COPYRIGHT 2007 RAISONANCE S.A.S. ********************
|
||||
* File Name : stm32f10x_it.c
|
||||
* Author : IB/FL
|
||||
* Date First Issued : 07/2007
|
||||
* Description : Interrupt handler for the CircleOS project.
|
||||
* Revision :
|
||||
*******************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F10x_IT_H
|
||||
#define __STM32F10x_IT_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f10x_lib.h"
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void NMIException( void );
|
||||
void HardFaultException( void );
|
||||
void MemManageException( void );
|
||||
void BusFaultException( void );
|
||||
void UsageFaultException( void );
|
||||
void DebugMonitor( void );
|
||||
void SVCHandler( void );
|
||||
void PendSVC( void );
|
||||
void SysTickHandler( void );
|
||||
void WWDG_IRQHandler( void );
|
||||
void PVD_IRQHandler( void );
|
||||
void TAMPER_IRQHandler( void );
|
||||
void RTC_IRQHandler( void );
|
||||
void FLASH_IRQHandler( void );
|
||||
void RCC_IRQHandler( void );
|
||||
void EXTI0_IRQHandler( void );
|
||||
void EXTI1_IRQHandler( void );
|
||||
void EXTI2_IRQHandler( void );
|
||||
void EXTI3_IRQHandler( void );
|
||||
void EXTI4_IRQHandler( void );
|
||||
void DMAChannel1_IRQHandler( void );
|
||||
void DMAChannel2_IRQHandler( void );
|
||||
void DMAChannel3_IRQHandler( void );
|
||||
void DMAChannel4_IRQHandler( void );
|
||||
void DMAChannel5_IRQHandler( void );
|
||||
void DMAChannel6_IRQHandler( void );
|
||||
void DMAChannel7_IRQHandler( void );
|
||||
void ADC_IRQHandler( void );
|
||||
void USB_HP_CAN_TX_IRQHandler( void );
|
||||
void USB_LP_CAN_RX0_IRQHandler( void );
|
||||
void CAN_RX1_IRQHandler( void );
|
||||
void CAN_SCE_IRQHandler( void );
|
||||
void EXTI9_5_IRQHandler( void );
|
||||
void TIM1_BRK_IRQHandler( void );
|
||||
void TIM1_UP_IRQHandler( void );
|
||||
void TIM1_TRG_COM_IRQHandler( void );
|
||||
void TIM1_CC_IRQHandler( void );
|
||||
void TIM2_IRQHandler( void );
|
||||
void TIM3_IRQHandler( void );
|
||||
void TIM4_IRQHandler( void );
|
||||
void I2C1_EV_IRQHandler( void );
|
||||
void I2C1_ER_IRQHandler( void );
|
||||
void I2C2_EV_IRQHandler( void );
|
||||
void I2C2_ER_IRQHandler( void );
|
||||
void SPI1_IRQHandler( void );
|
||||
void SPI2_IRQHandler( void );
|
||||
void USART1_IRQHandler( void );
|
||||
void USART2_IRQHandler( void );
|
||||
void USART3_IRQHandler( void );
|
||||
void EXTI15_10_IRQHandler( void );
|
||||
void RTCAlarm_IRQHandler( void );
|
||||
void USBWakeUp_IRQHandler( void );
|
||||
|
||||
#endif /* __STM32F10x_IT_H */
|
||||
2348
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/stm32f10x_tim.c
Normal file
2348
Demo/CORTEX_STM32F103_Primer_GCC/ST_Code/stm32f10x_tim.c
Normal file
File diff suppressed because it is too large
Load Diff
3361
Demo/CORTEX_STM32F103_Primer_GCC/bitmap.h
Normal file
3361
Demo/CORTEX_STM32F103_Primer_GCC/bitmap.h
Normal file
File diff suppressed because it is too large
Load Diff
465
Demo/CORTEX_STM32F103_Primer_GCC/main.c
Normal file
465
Demo/CORTEX_STM32F103_Primer_GCC/main.c
Normal file
@@ -0,0 +1,465 @@
|
||||
/*
|
||||
FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 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.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com a version that has been certified for use
|
||||
in safety critical systems, plus commercial licensing, development and
|
||||
support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Creates all the demo application tasks, then starts the scheduler. The WEB
|
||||
* documentation provides more details of the standard demo application tasks.
|
||||
* In addition to the standard demo tasks, the following tasks and tests are
|
||||
* defined and/or created within this file:
|
||||
*
|
||||
* "Fast Interrupt Test" - A high frequency periodic interrupt is generated
|
||||
* using a free running timer to demonstrate the use of the
|
||||
* configKERNEL_INTERRUPT_PRIORITY configuration constant. The interrupt
|
||||
* service routine measures the number of processor clocks that occur between
|
||||
* each interrupt - and in so doing measures the jitter in the interrupt timing.
|
||||
* The maximum measured jitter time is latched in the ulMaxJitter variable, and
|
||||
* displayed on the LCD by the 'Check' task as described below. The
|
||||
* fast interrupt is configured and handled in the timertest.c source file.
|
||||
*
|
||||
* "LCD" task - the LCD task is a 'gatekeeper' task. It is the only task that
|
||||
* is permitted to access the display directly. Other tasks wishing to write a
|
||||
* message to the LCD send the message on a queue to the LCD task instead of
|
||||
* accessing the LCD themselves. The LCD task just blocks on the queue waiting
|
||||
* for messages - waking and displaying the messages as they arrive. Messages
|
||||
* can either be a text string to display, or an instruction to update MEMS
|
||||
* input. The MEMS input is used to display a ball that can be moved around
|
||||
* LCD by tilting the STM32 Primer. 45% is taken as the neutral position.
|
||||
*
|
||||
* "Check" task - This only executes every five seconds but has the highest
|
||||
* priority so is guaranteed to get processor time. Its main function is to
|
||||
* check that all the standard demo tasks are still operational. Should any
|
||||
* unexpected behaviour within a demo task be discovered the 'check' task will
|
||||
* write an error to the LCD (via the LCD task). If all the demo tasks are
|
||||
* executing with their expected behaviour then the check task writes PASS
|
||||
* along with the max jitter time to the LCD (again via the LCD task), as
|
||||
* described above.
|
||||
*
|
||||
* Tick Hook - A tick hook is provided just for demonstration purposes. In
|
||||
* this case it is used to periodically send an instruction to updated the
|
||||
* MEMS input to the LCD task.
|
||||
*
|
||||
*/
|
||||
|
||||
/* CircleOS includes. Some of the CircleOS peripheral functionality is
|
||||
utilised, although CircleOS itself is not used. */
|
||||
#include "circle.h"
|
||||
|
||||
/* Standard includes. */
|
||||
#include <string.h>
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
#include "Queue.h"
|
||||
|
||||
/* Demo app includes. */
|
||||
#include "BlockQ.h"
|
||||
#include "blocktim.h"
|
||||
#include "GenQTest.h"
|
||||
#include "partest.h"
|
||||
#include "QPeek.h"
|
||||
|
||||
/* The bitmap used to display the FreeRTOS.org logo is stored in 16bit format
|
||||
and therefore takes up a large proportion of the Flash space. Setting this
|
||||
parameter to 0 excludes the bitmap from the build, freeing up Flash space for
|
||||
extra code. */
|
||||
#define mainINCLUDE_BITMAP 1
|
||||
|
||||
#if mainINCLUDE_BITMAP == 1
|
||||
#include "bitmap.h"
|
||||
#endif
|
||||
|
||||
/* Task priorities. */
|
||||
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
|
||||
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
#define mainGEN_Q_PRIORITY ( tskIDLE_PRIORITY + 0 )
|
||||
#define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
|
||||
|
||||
/* Splash screen related constants. */
|
||||
#define mainBITMAP_Y ( 38 )
|
||||
#define mainBITMAP_X ( 18 )
|
||||
#define mainURL_Y ( 8 )
|
||||
#define mainURL_X ( 78 )
|
||||
#define mainSPLASH_SCREEN_DELAY ( 2000 / portTICK_RATE_MS )
|
||||
|
||||
/* Text drawing related constants. */
|
||||
#define mainLCD_CHAR_HEIGHT ( 13 )
|
||||
#define mainLCD_MAX_Y ( 110 )
|
||||
|
||||
/* The maximum number of message that can be waiting for display at any one
|
||||
time. */
|
||||
#define mainLCD_QUEUE_SIZE ( 3 )
|
||||
|
||||
/* The check task uses the sprintf function so requires a little more stack. */
|
||||
#define mainCHECK_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE + 50 )
|
||||
|
||||
/* The LCD task calls some of the CircleOS functions (for MEMS and LCD access),
|
||||
these can require a larger stack. */
|
||||
#define configLCD_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE + 50 )
|
||||
|
||||
/* Dimensions the buffer into which the jitter time is written. */
|
||||
#define mainMAX_MSG_LEN 25
|
||||
|
||||
/* The time between cycles of the 'check' task. */
|
||||
#define mainCHECK_DELAY ( ( portTickType ) 5000 / portTICK_RATE_MS )
|
||||
|
||||
/* The period at which the MEMS input should be updated. */
|
||||
#define mainMEMS_DELAY ( ( portTickType ) 100 / portTICK_RATE_MS )
|
||||
|
||||
/* The rate at which the flash task toggles the LED. */
|
||||
#define mainFLASH_DELAY ( ( portTickType ) 1000 / portTICK_RATE_MS )
|
||||
|
||||
/* The number of nano seconds between each processor clock. */
|
||||
#define mainNS_PER_CLOCK ( ( unsigned portLONG ) ( ( 1.0 / ( double ) configCPU_CLOCK_HZ ) * 1000000000.0 ) )
|
||||
|
||||
/* The two types of message that can be sent to the LCD task. */
|
||||
#define mainUPDATE_BALL_MESSAGE ( 0 )
|
||||
#define mainWRITE_STRING_MESSAGE ( 1 )
|
||||
|
||||
/* Type of the message sent to the LCD task. */
|
||||
typedef struct
|
||||
{
|
||||
portBASE_TYPE xMessageType;
|
||||
signed char *pcMessage;
|
||||
} xLCDMessage;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Configure the clocks, GPIO and other peripherals as required by the demo.
|
||||
*/
|
||||
static void prvSetupHardware( void );
|
||||
|
||||
/*
|
||||
* The LCD is written two by more than one task so is controlled by a
|
||||
* 'gatekeeper' task. This is the only task that is actually permitted to
|
||||
* access the LCD directly. Other tasks wanting to display a message send
|
||||
* the message to the gatekeeper.
|
||||
*/
|
||||
static void prvLCDTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Checks the status of all the demo tasks then prints a message to the
|
||||
* display. The message will be either PASS - and include in brackets the
|
||||
* maximum measured jitter time (as described at the to of the file), or a
|
||||
* message that describes which of the standard demo tasks an error has been
|
||||
* discovered in.
|
||||
*
|
||||
* Messages are not written directly to the terminal, but passed to prvLCDTask
|
||||
* via a queue.
|
||||
*
|
||||
* The check task also receives instructions to update the MEMS input, which
|
||||
* in turn can also lead to the LCD being updated.
|
||||
*/
|
||||
static void prvCheckTask( void *pvParameters );
|
||||
|
||||
/*
|
||||
* Configures the timers and interrupts for the fast interrupt test as
|
||||
* described at the top of this file.
|
||||
*/
|
||||
extern void vSetupTimerTest( void );
|
||||
|
||||
/*
|
||||
* A cut down version of sprintf() used to percent the HUGE GCC library
|
||||
* equivalent from being included in the binary image.
|
||||
*/
|
||||
extern int sprintf(char *out, const char *format, ...);
|
||||
|
||||
/*
|
||||
* Simple toggle the LED periodically for timing verification.
|
||||
*/
|
||||
static void prvFlashTask( void *pvParameters );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The queue used to send messages to the LCD task. */
|
||||
xQueueHandle xLCDQueue;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int main( void )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
debug();
|
||||
#endif
|
||||
|
||||
prvSetupHardware();
|
||||
|
||||
/* Create the queue used by the LCD task. Messages for display on the LCD
|
||||
are received via this queue. */
|
||||
xLCDQueue = xQueueCreate( mainLCD_QUEUE_SIZE, sizeof( xLCDMessage ) );
|
||||
|
||||
/* Start the standard demo tasks. */
|
||||
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
|
||||
vCreateBlockTimeTasks();
|
||||
vStartGenericQueueTasks( mainGEN_Q_PRIORITY );
|
||||
vStartQueuePeekTasks();
|
||||
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
|
||||
|
||||
/* Start the tasks defined within this file/specific to this demo. */
|
||||
xTaskCreate( prvCheckTask, ( signed portCHAR * ) "Check", mainCHECK_TASK_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
|
||||
xTaskCreate( prvLCDTask, ( signed portCHAR * ) "LCD", configLCD_TASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( prvFlashTask, ( signed portCHAR * ) "Flash", configMINIMAL_STACK_SIZE, NULL, mainFLASH_TASK_PRIORITY, NULL );
|
||||
|
||||
/* Configure the timers used by the fast interrupt timer test. */
|
||||
vSetupTimerTest();
|
||||
|
||||
/* Start the scheduler. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* Will only get here if there was not enough heap space to create the
|
||||
idle task. */
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void prvLCDTask( void *pvParameters )
|
||||
{
|
||||
xLCDMessage xMessage;
|
||||
portCHAR cY = mainLCD_CHAR_HEIGHT;
|
||||
const portCHAR * const pcString = "www.FreeRTOS.org";
|
||||
const portCHAR * const pcBlankLine = " ";
|
||||
|
||||
DRAW_Init();
|
||||
|
||||
#if mainINCLUDE_BITMAP == 1
|
||||
DRAW_SetImage( pucImage, mainBITMAP_Y, mainBITMAP_X, bmpBITMAP_HEIGHT, bmpBITMAP_WIDTH );
|
||||
#endif
|
||||
|
||||
LCD_SetScreenOrientation( V9 );
|
||||
DRAW_DisplayString( mainURL_Y, mainURL_X, pcString, strlen( pcString ) );
|
||||
vTaskDelay( mainSPLASH_SCREEN_DELAY );
|
||||
LCD_FillRect( 0, 0, CHIP_SCREEN_WIDTH, CHIP_SCREEN_HEIGHT, RGB_WHITE );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Wait for a message to arrive that requires displaying. */
|
||||
while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );
|
||||
|
||||
/* Check the message type. */
|
||||
if( xMessage.xMessageType == mainUPDATE_BALL_MESSAGE )
|
||||
{
|
||||
/* Read the MEMS and update the ball display on the LCD if required. */
|
||||
MEMS_Handler();
|
||||
POINTER_Handler();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* A text string was sent. First blank off the old text string, then
|
||||
draw the new text on the next line down. */
|
||||
DRAW_DisplayString( 0, cY, pcBlankLine, strlen( pcBlankLine ) );
|
||||
|
||||
cY -= mainLCD_CHAR_HEIGHT;
|
||||
if( cY <= ( mainLCD_CHAR_HEIGHT - 1 ) )
|
||||
{
|
||||
/* Wrap the line onto which we are going to write the text. */
|
||||
cY = mainLCD_MAX_Y;
|
||||
}
|
||||
|
||||
/* Display the message. */
|
||||
DRAW_DisplayString( 0, cY, xMessage.pcMessage, strlen( xMessage.pcMessage ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCheckTask( void *pvParameters )
|
||||
{
|
||||
portTickType xLastExecutionTime;
|
||||
xLCDMessage xMessage;
|
||||
static signed portCHAR cPassMessage[ mainMAX_MSG_LEN ];
|
||||
extern unsigned portSHORT usMaxJitter;
|
||||
|
||||
/* Initialise the xLastExecutionTime variable on task entry. */
|
||||
xLastExecutionTime = xTaskGetTickCount();
|
||||
|
||||
/* Setup the message we are going to send to the LCD task. */
|
||||
xMessage.xMessageType = mainWRITE_STRING_MESSAGE;
|
||||
xMessage.pcMessage = cPassMessage;
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Perform this check every mainCHECK_DELAY milliseconds. */
|
||||
vTaskDelayUntil( &xLastExecutionTime, mainCHECK_DELAY );
|
||||
|
||||
/* Has an error been found in any task? If so then point the text
|
||||
we are going to send to the LCD task to an error message instead of
|
||||
the PASS message. */
|
||||
if( xAreGenericQueueTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN GEN Q";
|
||||
}
|
||||
if( xAreBlockingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN BLOCK Q";
|
||||
}
|
||||
else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN BLOCK TIME";
|
||||
}
|
||||
else if( xArePollingQueuesStillRunning() != pdTRUE )
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN POLL Q";
|
||||
}
|
||||
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
|
||||
{
|
||||
xMessage.pcMessage = "ERROR IN PEEK Q";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No errors were found in any task, so send a pass message
|
||||
with the max measured jitter time also included (as per the
|
||||
fast interrupt test described at the top of this file and on
|
||||
the online documentation page for this demo application). */
|
||||
sprintf( ( portCHAR * ) cPassMessage, "PASS [%uns]", ( ( unsigned portLONG ) usMaxJitter ) * mainNS_PER_CLOCK );
|
||||
}
|
||||
|
||||
/* Send the message to the LCD gatekeeper for display. */
|
||||
xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vApplicationTickHook( void )
|
||||
{
|
||||
static unsigned portLONG ulCallCount;
|
||||
static const xLCDMessage xMemsMessage = { mainUPDATE_BALL_MESSAGE, NULL };
|
||||
|
||||
/* Periodically send a message to the LCD task telling it to update
|
||||
the MEMS input, and then if necessary the LCD. */
|
||||
ulCallCount++;
|
||||
if( ulCallCount >= mainMEMS_DELAY )
|
||||
{
|
||||
ulCallCount = 0;
|
||||
xQueueSendFromISR( xLCDQueue, &xMemsMessage, pdFALSE );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSetupHardware( void )
|
||||
{
|
||||
/* Start with the clocks in their expected state. */
|
||||
RCC_DeInit();
|
||||
|
||||
/* Enable HSE (high speed external clock). */
|
||||
RCC_HSEConfig( RCC_HSE_ON );
|
||||
|
||||
/* Wait till HSE is ready. */
|
||||
while( RCC_GetFlagStatus( RCC_FLAG_HSERDY ) == RESET )
|
||||
{
|
||||
}
|
||||
|
||||
/* 2 wait states required on the flash. */
|
||||
*( ( unsigned portLONG * ) 0x40022000 ) = 0x02;
|
||||
|
||||
/* HCLK = SYSCLK */
|
||||
RCC_HCLKConfig( RCC_SYSCLK_Div1 );
|
||||
|
||||
/* PCLK2 = HCLK */
|
||||
RCC_PCLK2Config( RCC_HCLK_Div1 );
|
||||
|
||||
/* PCLK1 = HCLK/2 */
|
||||
RCC_PCLK1Config( RCC_HCLK_Div2 );
|
||||
|
||||
/* PLLCLK = 12MHz * 6 = 72 MHz. */
|
||||
RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_6 );
|
||||
|
||||
/* Enable PLL. */
|
||||
RCC_PLLCmd( ENABLE );
|
||||
|
||||
/* Wait till PLL is ready. */
|
||||
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
|
||||
{
|
||||
}
|
||||
|
||||
/* Select PLL as system clock source. */
|
||||
RCC_SYSCLKConfig( RCC_SYSCLKSource_PLLCLK );
|
||||
|
||||
/* Wait till PLL is used as system clock source. */
|
||||
while( RCC_GetSYSCLKSource() != 0x08 )
|
||||
{
|
||||
}
|
||||
|
||||
/* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */
|
||||
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC
|
||||
| RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE );
|
||||
|
||||
/* SPI2 Periph clock enable */
|
||||
RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI2, ENABLE );
|
||||
|
||||
|
||||
/* Set the Vector Table base address at 0x08000000 */
|
||||
NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );
|
||||
|
||||
NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );
|
||||
|
||||
/* Configure HCLK clock as SysTick clock source. */
|
||||
SysTick_CLKSourceConfig( SysTick_CLKSource_HCLK );
|
||||
|
||||
/* Misc initialisation, including some of the CircleOS features. Note
|
||||
that CircleOS itself is not used. */
|
||||
vParTestInitialise();
|
||||
MEMS_Init();
|
||||
POINTER_Init();
|
||||
POINTER_SetMode( POINTER_RESTORE_LESS );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvFlashTask( void *pvParameters )
|
||||
{
|
||||
portTickType xLastExecutionTime;
|
||||
|
||||
/* Initialise the xLastExecutionTime variable on task entry. */
|
||||
xLastExecutionTime = xTaskGetTickCount();
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* Simple toggle the LED periodically. This just provides some timing
|
||||
verification. */
|
||||
vTaskDelayUntil( &xLastExecutionTime, mainFLASH_DELAY );
|
||||
vParTestToggleLED( 0 );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void starting_delay( unsigned long ul )
|
||||
{
|
||||
vTaskDelay( ( portTickType ) ul );
|
||||
}
|
||||
|
||||
|
||||
|
||||
280
Demo/CORTEX_STM32F103_Primer_GCC/printf-stdarg.c
Normal file
280
Demo/CORTEX_STM32F103_Primer_GCC/printf-stdarg.c
Normal file
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
Copyright 2001, 2002 Georges Menie (www.menie.org)
|
||||
stdarg version contributed by Christian Ettinger
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
putchar is the only external dependency for this file,
|
||||
if you have a working putchar, leave it commented out.
|
||||
If not, uncomment the define below and
|
||||
replace outbyte(c) by your own function call.
|
||||
|
||||
#define putchar(c) outbyte(c)
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
static void printchar(char **str, int c)
|
||||
{
|
||||
extern int putchar(int c);
|
||||
|
||||
if (str) {
|
||||
**str = c;
|
||||
++(*str);
|
||||
}
|
||||
else (void)putchar(c);
|
||||
}
|
||||
|
||||
#define PAD_RIGHT 1
|
||||
#define PAD_ZERO 2
|
||||
|
||||
static int prints(char **out, const char *string, int width, int pad)
|
||||
{
|
||||
register int pc = 0, padchar = ' ';
|
||||
|
||||
if (width > 0) {
|
||||
register int len = 0;
|
||||
register const char *ptr;
|
||||
for (ptr = string; *ptr; ++ptr) ++len;
|
||||
if (len >= width) width = 0;
|
||||
else width -= len;
|
||||
if (pad & PAD_ZERO) padchar = '0';
|
||||
}
|
||||
if (!(pad & PAD_RIGHT)) {
|
||||
for ( ; width > 0; --width) {
|
||||
printchar (out, padchar);
|
||||
++pc;
|
||||
}
|
||||
}
|
||||
for ( ; *string ; ++string) {
|
||||
printchar (out, *string);
|
||||
++pc;
|
||||
}
|
||||
for ( ; width > 0; --width) {
|
||||
printchar (out, padchar);
|
||||
++pc;
|
||||
}
|
||||
|
||||
return pc;
|
||||
}
|
||||
|
||||
/* the following should be enough for 32 bit int */
|
||||
#define PRINT_BUF_LEN 12
|
||||
|
||||
static int printi(char **out, int i, int b, int sg, int width, int pad, int letbase)
|
||||
{
|
||||
char print_buf[PRINT_BUF_LEN];
|
||||
register char *s;
|
||||
register int t, neg = 0, pc = 0;
|
||||
register unsigned int u = i;
|
||||
|
||||
if (i == 0) {
|
||||
print_buf[0] = '0';
|
||||
print_buf[1] = '\0';
|
||||
return prints (out, print_buf, width, pad);
|
||||
}
|
||||
|
||||
if (sg && b == 10 && i < 0) {
|
||||
neg = 1;
|
||||
u = -i;
|
||||
}
|
||||
|
||||
s = print_buf + PRINT_BUF_LEN-1;
|
||||
*s = '\0';
|
||||
|
||||
while (u) {
|
||||
t = u % b;
|
||||
if( t >= 10 )
|
||||
t += letbase - '0' - 10;
|
||||
*--s = t + '0';
|
||||
u /= b;
|
||||
}
|
||||
|
||||
if (neg) {
|
||||
if( width && (pad & PAD_ZERO) ) {
|
||||
printchar (out, '-');
|
||||
++pc;
|
||||
--width;
|
||||
}
|
||||
else {
|
||||
*--s = '-';
|
||||
}
|
||||
}
|
||||
|
||||
return pc + prints (out, s, width, pad);
|
||||
}
|
||||
|
||||
static int print( char **out, const char *format, va_list args )
|
||||
{
|
||||
register int width, pad;
|
||||
register int pc = 0;
|
||||
char scr[2];
|
||||
|
||||
for (; *format != 0; ++format) {
|
||||
if (*format == '%') {
|
||||
++format;
|
||||
width = pad = 0;
|
||||
if (*format == '\0') break;
|
||||
if (*format == '%') goto out;
|
||||
if (*format == '-') {
|
||||
++format;
|
||||
pad = PAD_RIGHT;
|
||||
}
|
||||
while (*format == '0') {
|
||||
++format;
|
||||
pad |= PAD_ZERO;
|
||||
}
|
||||
for ( ; *format >= '0' && *format <= '9'; ++format) {
|
||||
width *= 10;
|
||||
width += *format - '0';
|
||||
}
|
||||
if( *format == 's' ) {
|
||||
register char *s = (char *)va_arg( args, int );
|
||||
pc += prints (out, s?s:"(null)", width, pad);
|
||||
continue;
|
||||
}
|
||||
if( *format == 'd' ) {
|
||||
pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
|
||||
continue;
|
||||
}
|
||||
if( *format == 'x' ) {
|
||||
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
|
||||
continue;
|
||||
}
|
||||
if( *format == 'X' ) {
|
||||
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
|
||||
continue;
|
||||
}
|
||||
if( *format == 'u' ) {
|
||||
pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
|
||||
continue;
|
||||
}
|
||||
if( *format == 'c' ) {
|
||||
/* char are converted to int then pushed on the stack */
|
||||
scr[0] = (char)va_arg( args, int );
|
||||
scr[1] = '\0';
|
||||
pc += prints (out, scr, width, pad);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
out:
|
||||
printchar (out, *format);
|
||||
++pc;
|
||||
}
|
||||
}
|
||||
if (out) **out = '\0';
|
||||
va_end( args );
|
||||
return pc;
|
||||
}
|
||||
|
||||
int printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
return print( 0, format, args );
|
||||
}
|
||||
|
||||
int sprintf(char *out, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, format );
|
||||
return print( &out, format, args );
|
||||
}
|
||||
|
||||
|
||||
int snprintf( char *buf, unsigned int count, const char *format, ... )
|
||||
{
|
||||
va_list args;
|
||||
|
||||
( void ) count;
|
||||
|
||||
va_start( args, format );
|
||||
return print( &buf, format, args );
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST_PRINTF
|
||||
int main(void)
|
||||
{
|
||||
char *ptr = "Hello world!";
|
||||
char *np = 0;
|
||||
int i = 5;
|
||||
unsigned int bs = sizeof(int)*8;
|
||||
int mi;
|
||||
char buf[80];
|
||||
|
||||
mi = (1 << (bs-1)) + 1;
|
||||
printf("%s\n", ptr);
|
||||
printf("printf test\n");
|
||||
printf("%s is null pointer\n", np);
|
||||
printf("%d = 5\n", i);
|
||||
printf("%d = - max int\n", mi);
|
||||
printf("char %c = 'a'\n", 'a');
|
||||
printf("hex %x = ff\n", 0xff);
|
||||
printf("hex %02x = 00\n", 0);
|
||||
printf("signed %d = unsigned %u = hex %x\n", -3, -3, -3);
|
||||
printf("%d %s(s)%", 0, "message");
|
||||
printf("\n");
|
||||
printf("%d %s(s) with %%\n", 0, "message");
|
||||
sprintf(buf, "justif: \"%-10s\"\n", "left"); printf("%s", buf);
|
||||
sprintf(buf, "justif: \"%10s\"\n", "right"); printf("%s", buf);
|
||||
sprintf(buf, " 3: %04d zero padded\n", 3); printf("%s", buf);
|
||||
sprintf(buf, " 3: %-4d left justif.\n", 3); printf("%s", buf);
|
||||
sprintf(buf, " 3: %4d right justif.\n", 3); printf("%s", buf);
|
||||
sprintf(buf, "-3: %04d zero padded\n", -3); printf("%s", buf);
|
||||
sprintf(buf, "-3: %-4d left justif.\n", -3); printf("%s", buf);
|
||||
sprintf(buf, "-3: %4d right justif.\n", -3); printf("%s", buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* if you compile this file with
|
||||
* gcc -Wall $(YOUR_C_OPTIONS) -DTEST_PRINTF -c printf.c
|
||||
* you will get a normal warning:
|
||||
* printf.c:214: warning: spurious trailing `%' in format
|
||||
* this line is testing an invalid % at the end of the format string.
|
||||
*
|
||||
* this should display (on 32bit int machine) :
|
||||
*
|
||||
* Hello world!
|
||||
* printf test
|
||||
* (null) is null pointer
|
||||
* 5 = 5
|
||||
* -2147483647 = - max int
|
||||
* char a = 'a'
|
||||
* hex ff = ff
|
||||
* hex 00 = 00
|
||||
* signed -3 = unsigned 4294967293 = hex fffffffd
|
||||
* 0 message(s)
|
||||
* 0 message(s) with %
|
||||
* justif: "left "
|
||||
* justif: " right"
|
||||
* 3: 0003 zero padded
|
||||
* 3: 3 left justif.
|
||||
* 3: 3 right justif.
|
||||
* -3: -003 zero padded
|
||||
* -3: -3 left justif.
|
||||
* -3: -3 right justif.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
170
Demo/CORTEX_STM32F103_Primer_GCC/timertest.c
Normal file
170
Demo/CORTEX_STM32F103_Primer_GCC/timertest.c
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
FreeRTOS.org V4.6.1 - Copyright (C) 2003-2007 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.
|
||||
|
||||
***************************************************************************
|
||||
See http://www.FreeRTOS.org for documentation, latest information, license
|
||||
and contact details. Please ensure to read the configuration and relevant
|
||||
port sections of the online documentation.
|
||||
|
||||
Also see http://www.SafeRTOS.com a version that has been certified for use
|
||||
in safety critical systems, plus commercial licensing, development and
|
||||
support options.
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/* High speed timer test as described in main.c. */
|
||||
|
||||
/* Scheduler includes. */
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
/* Library includes. */
|
||||
#include "stm32f10x_lib.h"
|
||||
#include "stm32f10x_tim.h"
|
||||
#include "stm32f10x_map.h"
|
||||
|
||||
/* The set frequency of the interrupt. Deviations from this are measured as
|
||||
the jitter. */
|
||||
#define timerINTERRUPT_FREQUENCY ( ( unsigned portSHORT ) 20000 )
|
||||
|
||||
/* The expected time between each of the timer interrupts - if the jitter was
|
||||
zero. */
|
||||
#define timerEXPECTED_DIFFERENCE_VALUE ( configCPU_CLOCK_HZ / timerINTERRUPT_FREQUENCY )
|
||||
|
||||
/* The highest available interrupt priority. */
|
||||
#define timerHIGHEST_PRIORITY ( 0 )
|
||||
|
||||
/* Misc defines. */
|
||||
#define timerMAX_32BIT_VALUE ( 0xffffffffUL )
|
||||
#define timerTIMER_1_COUNT_VALUE ( * ( ( unsigned long * ) ( TIMER1_BASE + 0x48 ) ) )
|
||||
|
||||
/* The number of interrupts to pass before we start looking at the jitter. */
|
||||
#define timerSETTLE_TIME 5
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Configures the two timers used to perform the test.
|
||||
*/
|
||||
void vSetupTimerTest( void );
|
||||
|
||||
/* Interrupt handler in which the jitter is measured. */
|
||||
void vTimer2IntHandler( void );
|
||||
|
||||
/* Stores the value of the maximum recorded jitter between interrupts. */
|
||||
volatile unsigned portSHORT usMaxJitter = 0;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vSetupTimerTest( void )
|
||||
{
|
||||
unsigned long ulFrequency;
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
|
||||
|
||||
/* Enable timer clocks */
|
||||
RCC_APB1PeriphClockCmd( RCC_APB1Periph_TIM2, ENABLE );
|
||||
RCC_APB1PeriphClockCmd( RCC_APB1Periph_TIM3, ENABLE );
|
||||
|
||||
/* Initialise data. */
|
||||
TIM_DeInit( TIM2 );
|
||||
TIM_DeInit( TIM3 );
|
||||
TIM_TimeBaseStructInit( &TIM_TimeBaseStructure );
|
||||
|
||||
/* Time base configuration for timer 2 - which generates the interrupts. */
|
||||
ulFrequency = configCPU_CLOCK_HZ / timerINTERRUPT_FREQUENCY;
|
||||
TIM_TimeBaseStructure.TIM_Period = ( unsigned portSHORT ) ( ulFrequency & 0xffffUL );
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = 0x0;
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
TIM_TimeBaseInit( TIM2, &TIM_TimeBaseStructure );
|
||||
TIM_ARRPreloadConfig( TIM2, ENABLE );
|
||||
|
||||
|
||||
/* Configuration for timer 3 which is used as a high resolution time
|
||||
measurement. */
|
||||
TIM_TimeBaseStructure.TIM_Period = ( unsigned portSHORT ) 0xffff;
|
||||
TIM_TimeBaseInit( TIM3, &TIM_TimeBaseStructure );
|
||||
TIM_ARRPreloadConfig( TIM3, ENABLE );
|
||||
|
||||
/* Enable TIM2 IT. TIM3 does not generate an interrupt. */
|
||||
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQChannel;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = timerHIGHEST_PRIORITY;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init( &NVIC_InitStructure );
|
||||
TIM_ITConfig( TIM2, TIM_IT_Update, ENABLE );
|
||||
|
||||
/* Finally, enable both timers. */
|
||||
TIM_Cmd( TIM2, ENABLE );
|
||||
TIM_Cmd( TIM3, ENABLE );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vTimer2IntHandler( void )
|
||||
{
|
||||
static unsigned portSHORT usLastCount = 0, usSettleCount = 0, usMaxDifference = 0;
|
||||
unsigned portSHORT usThisCount, usDifference;
|
||||
|
||||
/* Capture the free running timer 3 value as we enter the interrupt. */
|
||||
usThisCount = TIM3->CNT;
|
||||
|
||||
if( usSettleCount >= timerSETTLE_TIME )
|
||||
{
|
||||
/* What is the difference between the timer value in this interrupt
|
||||
and the value from the last interrupt. */
|
||||
usDifference = usThisCount - usLastCount;
|
||||
|
||||
/* Store the difference in the timer values if it is larger than the
|
||||
currently stored largest value. The difference over and above the
|
||||
expected difference will give the 'jitter' in the processing of these
|
||||
interrupts. */
|
||||
if( usDifference > usMaxDifference )
|
||||
{
|
||||
usMaxDifference = usDifference;
|
||||
usMaxJitter = usMaxDifference - timerEXPECTED_DIFFERENCE_VALUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Don't bother storing any values for the first couple of
|
||||
interrupts. */
|
||||
usSettleCount++;
|
||||
}
|
||||
|
||||
/* Remember what the timer value was this time through, so we can calculate
|
||||
the difference the next time through. */
|
||||
usLastCount = usThisCount;
|
||||
|
||||
TIM_ClearITPendingBit( TIM2, TIM_IT_Update );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -153,6 +153,10 @@
|
||||
#include "../../Source/portable/GCC/ARM_CM3/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef GCC_ARMCM3
|
||||
#include "../../Source/portable/GCC/ARM_CM3/portmacro.h"
|
||||
#endif
|
||||
|
||||
#ifdef IAR_ARM_CM3
|
||||
#include "../../Source/portable/IAR/ARM_CM3/portmacro.h"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user