aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-04-08 15:34:54 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-04-08 15:34:54 +0000
commit72dcfa88663999e2484463eaaa97ab861f2c7a19 (patch)
treea52673df03a5974998fa0f677b4c7686730ef02e
parent735ba4c4ead1f994c3911add3bee13c14463b0db (diff)
downloadChibiOS-72dcfa88663999e2484463eaaa97ab861f2c7a19.tar.gz
ChibiOS-72dcfa88663999e2484463eaaa97ab861f2c7a19.tar.bz2
ChibiOS-72dcfa88663999e2484463eaaa97ab861f2c7a19.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@256 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/ARMCM3-STM32F103-GCC/board.c20
-rw-r--r--demos/ARMCM3-STM32F103-GCC/board.h39
-rw-r--r--demos/ARMCM3-STM32F103-GCC/stm32lib/stm32f10x_conf.h20
-rw-r--r--ports/ARMCM3/chcore.c4
4 files changed, 71 insertions, 12 deletions
diff --git a/demos/ARMCM3-STM32F103-GCC/board.c b/demos/ARMCM3-STM32F103-GCC/board.c
index ec5ac2fb4..1d689bee8 100644
--- a/demos/ARMCM3-STM32F103-GCC/board.c
+++ b/demos/ARMCM3-STM32F103-GCC/board.c
@@ -19,10 +19,30 @@
#include <ch.h>
+#include "board.h"
+
/*
* Hardware initialization goes here.
* NOTE: Interrupts are still disabled.
*/
void hwinit(void) {
+ /*
+ * I/O ports initialization as specified in board.h.
+ */
+ GPIOA->CRL = VAL_GPIOACRL;
+ GPIOA->CRH = VAL_GPIOACRH;
+ GPIOA->ODR = VAL_GPIOAODR;
+
+ GPIOB->CRL = VAL_GPIOBCRL;
+ GPIOB->CRH = VAL_GPIOBCRH;
+ GPIOB->ODR = VAL_GPIOBODR;
+
+ GPIOC->CRL = VAL_GPIOCCRL;
+ GPIOC->CRH = VAL_GPIOCCRH;
+ GPIOC->ODR = VAL_GPIOCODR;
+
+ GPIOD->CRL = VAL_GPIODCRL;
+ GPIOD->CRH = VAL_GPIODCRH;
+ GPIOD->ODR = VAL_GPIODODR;
}
diff --git a/demos/ARMCM3-STM32F103-GCC/board.h b/demos/ARMCM3-STM32F103-GCC/board.h
index 88459c3e7..cdb9d2588 100644
--- a/demos/ARMCM3-STM32F103-GCC/board.h
+++ b/demos/ARMCM3-STM32F103-GCC/board.h
@@ -20,6 +20,45 @@
#ifndef _BOARD_H_
#define _BOARD_H_
+#undef FALSE
+#undef TRUE
+#ifndef __STM32F10x_MAP_H
+#include "stm32lib/stm32f10x_map.h"
+#endif
+
#define BOARD_OLIMEX_STM32_P103
+#define LSECLK 32768
+#define HSECLK 8000000
+#define PLLDIV 1
+#define PLLMUL 9
+#define PLLCLK ((HSECLK / PLLDIV) * PLLMUL)
+
+#define GPIOA_BUTTON (1 << 0)
+
+#define GPIOC_MMCWP (1 << 6)
+#define GPIOC_MMCCP (1 << 7)
+#define GPIOC_CANCNTL (1 << 10)
+#define GPIOC_DISC (1 << 11)
+#define GPIOC_LED (1 << 12)
+
+/*
+ * All inputs with pullups unless otherwise specified.
+ */
+#define VAL_GPIOACRL 0x88888884 // PA0:FI
+#define VAL_GPIOACRH 0x88888888
+#define VAL_GPIOAODR 0xFFFFFFFF
+
+#define VAL_GPIOBCRL 0x88883888 // PB3:PP
+#define VAL_GPIOBCRH 0x88888888
+#define VAL_GPIOBODR 0xFFFFFFFF
+
+#define VAL_GPIOCCRL 0x44888888 // PC6,PC7:FI
+#define VAL_GPIOCCRH 0x88833888 // PC11,PC12:PP
+#define VAL_GPIOCODR 0xFFFFFFFF
+
+#define VAL_GPIODCRL 0x88888844 // PD0,PD1:FI
+#define VAL_GPIODCRH 0x88888888
+#define VAL_GPIODODR 0xFFFFFFFF
+
#endif /* _BOARD_H_ */
diff --git a/demos/ARMCM3-STM32F103-GCC/stm32lib/stm32f10x_conf.h b/demos/ARMCM3-STM32F103-GCC/stm32lib/stm32f10x_conf.h
index 59ae65d01..8e51a48fd 100644
--- a/demos/ARMCM3-STM32F103-GCC/stm32lib/stm32f10x_conf.h
+++ b/demos/ARMCM3-STM32F103-GCC/stm32lib/stm32f10x_conf.h
@@ -34,7 +34,7 @@
//#define _ADC2
/************************************* BKP ************************************/
-//#define _BKP
+//#define _BKP
/************************************* CAN ************************************/
//#define _CAN
@@ -60,11 +60,11 @@
/* #define _FLASH_PROG */
/************************************* GPIO ***********************************/
-//#define _GPIO
-//#define _GPIOA
-//#define _GPIOB
-//#define _GPIOC
-//#define _GPIOD
+#define _GPIO
+#define _GPIOA
+#define _GPIOB
+#define _GPIOC
+#define _GPIOD
//#define _GPIOE
//#define _AFIO
@@ -94,7 +94,7 @@
//#define _SPI2
/************************************* SysTick ********************************/
-//#define _SysTick
+#define _SysTick
/************************************* TIM1 ***********************************/
//#define _TIM1
@@ -123,13 +123,13 @@
/*******************************************************************************
* Macro Name : assert_param
* Description : The assert_param macro is used for function's parameters check.
-* It is used only if the library is compiled in DEBUG mode.
+* It is used only if the library is compiled in DEBUG mode.
* Input : - expr: If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
-* line number of the call that failed.
+* line number of the call that failed.
* If expr is true, it returns no value.
* Return : None
-*******************************************************************************/
+*******************************************************************************/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((u8 *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(u8* file, u32 line);
diff --git a/ports/ARMCM3/chcore.c b/ports/ARMCM3/chcore.c
index 94a734dba..cb95916c3 100644
--- a/ports/ARMCM3/chcore.c
+++ b/ports/ARMCM3/chcore.c
@@ -70,8 +70,6 @@ void threadstart(void) {
"bl chThdExit ");
}
-void *retaddr;
-
/*
* System Timer vector.
*/
@@ -84,6 +82,8 @@ void SysTickVector(void) {
chSysIRQExitI();
}
+void *retaddr;
+
/*
* To be invoked at the end of any interrupt handler that can trigger a
* reschedule.