git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2134 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2010-08-20 07:15:55 +00:00
parent 4e26a3b42c
commit fef1911a8f
7 changed files with 209 additions and 4 deletions

View File

@ -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();
}

View File

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

View File

@ -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

View File

@ -28,6 +28,16 @@
#ifndef _CHSYS_H_ #ifndef _CHSYS_H_
#define _CHSYS_H_ #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. * @brief Halts the system.
* @details This function is invoked by the operating system when an * @details This function is invoked by the operating system when an
@ -168,9 +178,12 @@
*/ */
#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id) #define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
extern WORKING_AREA(_idle_thread_wa, IDLE_THREAD_STACK_SIZE);
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void _idle_thread(void *p);
void chSysInit(void); void chSysInit(void);
void chSysTimerHandlerI(void); void chSysTimerHandlerI(void);
#if CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED #if CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED

View File

@ -250,6 +250,15 @@ extern "C" {
*/ */
#define chThdGetPriority() (currp->p_prio) #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. * @brief Returns the pointer to the @p Thread local storage area, if any.
*/ */

View File

@ -34,7 +34,7 @@
#include "ch.h" #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. * @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 * @param[in] p the thread parameter, unused in this scenario
*/ */
static void idle_thread(void *p) { void _idle_thread(void *p) {
(void)p; (void)p;
while (TRUE) { while (TRUE) {
@ -87,8 +87,8 @@ void chSysInit(void) {
/* This thread has the lowest priority in the system, its role is just to /* 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 serve interrupts in its context while keeping the lowest energy saving
mode compatible with the system status.*/ mode compatible with the system status.*/
chThdCreateStatic(idle_thread_wa, sizeof(idle_thread_wa), IDLEPRIO, chThdCreateStatic(idle_thread_wa, sizeof(_idle_thread_wa), IDLEPRIO,
(tfunc_t)idle_thread, NULL); (tfunc_t)_idle_thread, NULL);
} }
/** /**

View File

@ -71,6 +71,9 @@
2.0.3). 2.0.3).
- FIX: Fixed a documentation error regarding the ADC driver function - FIX: Fixed a documentation error regarding the ADC driver function
adcStartConversion() (bug 3039890)(backported to 2.0.3). 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: New I2C device driver model (no implementations yet).
- NEW: Added to the UART driver the capability to return the number of - NEW: Added to the UART driver the capability to return the number of
not yet transferred frames when stopping an operation. not yet transferred frames when stopping an operation.