aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boards/OLIMEX_STM32_H103/board.c49
-rw-r--r--boards/OLIMEX_STM32_H103/board.h126
-rw-r--r--boards/OLIMEX_STM32_H103/board.mk5
-rw-r--r--os/kernel/include/chsys.h13
-rw-r--r--os/kernel/include/chthreads.h9
-rw-r--r--os/kernel/src/chsys.c8
-rw-r--r--readme.txt3
7 files changed, 209 insertions, 4 deletions
diff --git a/boards/OLIMEX_STM32_H103/board.c b/boards/OLIMEX_STM32_H103/board.c
new file mode 100644
index 000000000..77f958101
--- /dev/null
+++ b/boards/OLIMEX_STM32_H103/board.c
@@ -0,0 +1,49 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT 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 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT 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 this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "ch.h"
+#include "hal.h"
+
+/*
+ * Early initialization code.
+ * This initialization is performed just after reset before BSS and DATA
+ * segments initialization.
+ */
+void hwinit0(void) {
+
+ stm32_clock_init();
+}
+
+/*
+ * Late initialization code.
+ * This initialization is performed after BSS and DATA segments initialization
+ * and before invoking the main() function.
+ */
+void hwinit1(void) {
+
+ /*
+ * HAL initialization.
+ */
+ halInit();
+
+ /*
+ * ChibiOS/RT initialization.
+ */
+ chSysInit();
+}
diff --git a/boards/OLIMEX_STM32_H103/board.h b/boards/OLIMEX_STM32_H103/board.h
new file mode 100644
index 000000000..8010d415d
--- /dev/null
+++ b/boards/OLIMEX_STM32_H103/board.h
@@ -0,0 +1,126 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT 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 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT 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 this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _BOARD_H_
+#define _BOARD_H_
+
+/*
+ * Setup for the Olimex STM33-H103 proto board.
+ */
+
+/*
+ * Board identifier.
+ */
+#define BOARD_OLIMEX_STM32_H103
+#define BOARD_NAME "Olimex STM32-H103"
+
+/*
+ * Board frequencies.
+ */
+#define STM32_LSECLK 32768
+#define STM32_HSECLK 8000000
+
+/*
+ * MCU type, this macro is used by both the ST library and the ChibiOS/RT
+ * native STM32 HAL.
+ */
+#define STM32F10X_MD
+
+/*
+ * IO pins assignments.
+ */
+#define GPIOA_BUTTON 0
+
+#define GPIOC_DISC 11
+#define GPIOC_LED 12
+
+/*
+ * I/O ports initial setup, this configuration is established soon after reset
+ * in the initialization code.
+ *
+ * The digits have the following meaning:
+ * 0 - Analog input.
+ * 1 - Push Pull output 10MHz.
+ * 2 - Push Pull output 2MHz.
+ * 3 - Push Pull output 50MHz.
+ * 4 - Digital input.
+ * 5 - Open Drain output 10MHz.
+ * 6 - Open Drain output 2MHz.
+ * 7 - Open Drain output 50MHz.
+ * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
+ * 9 - Alternate Push Pull output 10MHz.
+ * A - Alternate Push Pull output 2MHz.
+ * B - Alternate Push Pull output 50MHz.
+ * C - Reserved.
+ * D - Alternate Open Drain output 10MHz.
+ * E - Alternate Open Drain output 2MHz.
+ * F - Alternate Open Drain output 50MHz.
+ * Please refer to the STM32 Reference Manual for details.
+ */
+
+/*
+ * Port A setup.
+ * Everything input with pull-up except:
+ * PA0 - Normal input (BUTTON).
+ * PA2 - Alternate output (USART2 TX).
+ * PA3 - Normal input (USART2 RX).
+ */
+#define VAL_GPIOACRL 0x88884B84 /* PA7...PA0 */
+#define VAL_GPIOACRH 0x88888888 /* PA15...PA8 */
+#define VAL_GPIOAODR 0xFFFFFFFF
+
+/*
+ * Port B setup.
+ * Everything input with pull-up except:
+ */
+#define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */
+#define VAL_GPIOBCRH 0x88888888 /* PB15...PB8 */
+#define VAL_GPIOBODR 0xFFFFFFFF
+
+/*
+ * Port C setup.
+ * Everything input with pull-up except:
+ * PC6 - Normal input because there is an external resistor.
+ * PC7 - Normal input because there is an external resistor.
+ * PC11 - Open Drain output (USB disconnect).
+ * PC12 - Push Pull output (LED).
+ */
+#define VAL_GPIOCCRL 0x44888888 /* PC7...PC0 */
+#define VAL_GPIOCCRH 0x88837888 /* PC15...PC8 */
+#define VAL_GPIOCODR 0xFFFFFFFF
+
+/*
+ * Port D setup.
+ * Everything input with pull-up except:
+ * PD0 - Normal input (XTAL).
+ * PD1 - Normal input (XTAL).
+ */
+#define VAL_GPIODCRL 0x88888844 /* PD7...PD0 */
+#define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */
+#define VAL_GPIODODR 0xFFFFFFFF
+
+/*
+ * Port E setup.
+ * Everything input with pull-up except:
+ */
+#define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */
+#define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
+#define VAL_GPIOEODR 0xFFFFFFFF
+
+#endif /* _BOARD_H_ */
diff --git a/boards/OLIMEX_STM32_H103/board.mk b/boards/OLIMEX_STM32_H103/board.mk
new file mode 100644
index 000000000..040374ffc
--- /dev/null
+++ b/boards/OLIMEX_STM32_H103/board.mk
@@ -0,0 +1,5 @@
+# List of all the board related files.
+BOARDSRC = ${CHIBIOS}/boards/OLIMEX_STM32_H103/board.c
+
+# Required include directories
+BOARDINC = ${CHIBIOS}/boards/OLIMEX_STM32_H103
diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h
index 5759d0cca..ae013d7c7 100644
--- a/os/kernel/include/chsys.h
+++ b/os/kernel/include/chsys.h
@@ -29,6 +29,16 @@
#define _CHSYS_H_
/**
+ * @brief Returns a pointer to the idle thread.
+ * @note The reference counter of the idle thread is not incremented but
+ * it is not strictly required being the idle thread a static
+ * object.
+ *
+ * @return Pointer to the idle thread,
+ */
+#define chSysGetIdleThread() ((Thread *)_idle_thread_wa)
+
+/**
* @brief Halts the system.
* @details This function is invoked by the operating system when an
* unrecoverable error is detected, as example because a programming
@@ -168,9 +178,12 @@
*/
#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
+extern WORKING_AREA(_idle_thread_wa, IDLE_THREAD_STACK_SIZE);
+
#ifdef __cplusplus
extern "C" {
#endif
+ void _idle_thread(void *p);
void chSysInit(void);
void chSysTimerHandlerI(void);
#if CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED
diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h
index 9eeff8666..1e659b768 100644
--- a/os/kernel/include/chthreads.h
+++ b/os/kernel/include/chthreads.h
@@ -251,6 +251,15 @@ extern "C" {
#define chThdGetPriority() (currp->p_prio)
/**
+ * @brief Returns the number of ticks consumed by the specified thread.
+ * @note This function is only available when the
+ * @p CH_DBG_THREADS_PROFILING configuration option is enabled.
+ *
+ * @param[in] tp the pointer to the thread
+ */
+#define chThdGetTicks(tp) ((tp)->p_time)
+
+/**
* @brief Returns the pointer to the @p Thread local storage area, if any.
*/
#define chThdLS() (void *)(currp + 1)
diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c
index 1a66c8e98..80d037dd6 100644
--- a/os/kernel/src/chsys.c
+++ b/os/kernel/src/chsys.c
@@ -34,7 +34,7 @@
#include "ch.h"
-static WORKING_AREA(idle_thread_wa, IDLE_THREAD_STACK_SIZE);
+WORKING_AREA(_idle_thread_wa, IDLE_THREAD_STACK_SIZE);
/**
* @brief This function implements the idle thread infinite loop.
@@ -46,7 +46,7 @@ static WORKING_AREA(idle_thread_wa, IDLE_THREAD_STACK_SIZE);
*
* @param[in] p the thread parameter, unused in this scenario
*/
-static void idle_thread(void *p) {
+void _idle_thread(void *p) {
(void)p;
while (TRUE) {
@@ -87,8 +87,8 @@ void chSysInit(void) {
/* This thread has the lowest priority in the system, its role is just to
serve interrupts in its context while keeping the lowest energy saving
mode compatible with the system status.*/
- chThdCreateStatic(idle_thread_wa, sizeof(idle_thread_wa), IDLEPRIO,
- (tfunc_t)idle_thread, NULL);
+ chThdCreateStatic(idle_thread_wa, sizeof(_idle_thread_wa), IDLEPRIO,
+ (tfunc_t)_idle_thread, NULL);
}
/**
diff --git a/readme.txt b/readme.txt
index dc19c922f..0f54b4ee8 100644
--- a/readme.txt
+++ b/readme.txt
@@ -71,6 +71,9 @@
2.0.3).
- FIX: Fixed a documentation error regarding the ADC driver function
adcStartConversion() (bug 3039890)(backported to 2.0.3).
+- NEW: Added board files for the Olimex STM32-H103.
+- NEW: New kernel APIs chSysGetIdleThread() and chThdGetTicks(), the new
+ APIs are simple macros so there is no footprint overhead.
- NEW: New I2C device driver model (no implementations yet).
- NEW: Added to the UART driver the capability to return the number of
not yet transferred frames when stopping an operation.