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

This commit is contained in:
gdisirio 2014-05-29 14:02:06 +00:00
parent f0a80283cb
commit 1764b2db55
11 changed files with 308 additions and 59 deletions

View File

@ -23,4 +23,11 @@
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
<linkedResources>
<link>
<name>os</name>
<type>2</type>
<locationURI>CHIBIOS/os</locationURI>
</link>
</linkedResources>
</projectDescription>

View File

@ -110,7 +110,7 @@ CHIBIOS = ../../..
#include $(CHIBIOS)/os/hal/ports/STM32/STM32F1xx/platform.mk
#include $(CHIBIOS)/os/hal/osal/rt/osal.mk
include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_lpc214x.mk
include $(CHIBIOS)/os/rt/ports/ARM/compilers/GCC/mk/port_lpc214x.mk
#include $(CHIBIOS)/test/rt/test.mk
# Define linker script file here

View File

@ -46,7 +46,7 @@
* @details Frequency of the system timer that drives the system ticks. This
* setting also defines the system tick time unit.
*/
#define CH_CFG_ST_FREQUENCY 10000
#define CH_CFG_ST_FREQUENCY 1000
/**
* @brief Time delta constant for the tick-less mode.
@ -56,7 +56,7 @@
* The value one is not valid, timeouts are rounded up to
* this value.
*/
#define CH_CFG_ST_TIMEDELTA 2
#define CH_CFG_ST_TIMEDELTA 0
/** @} */
@ -137,7 +137,7 @@
*
* @note The default is @p TRUE.
*/
#define CH_CFG_USE_TM TRUE
#define CH_CFG_USE_TM FALSE
/**
* @brief Threads registry APIs.

View File

@ -15,9 +15,10 @@
*/
#include "ch.h"
#include "hal.h"
#include "test.h"
//#include "hal.h"
//#include "test.h"
#if 0
#define BOTH_BUTTONS (PAL_PORT_BIT(PA_BUTTON1) | PAL_PORT_BIT(PA_BUTTON2))
/*
@ -57,6 +58,7 @@ static msg_t Thread2(void *arg) {
}
return 0;
}
#endif
/*
* Application entry point.
@ -70,22 +72,22 @@ int main(void) {
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
// halInit();
chSysInit();
/*
* Activates the serial driver 1 using the driver default configuration.
*/
sdStart(&SD1, NULL);
// sdStart(&SD1, NULL);
/*
* If a button is pressed during the reset then the blinking leds threads
* are not started in order to make accurate benchmarks.
*/
if ((palReadPort(IOPORT1) & BOTH_BUTTONS) == BOTH_BUTTONS) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
}
// if ((palReadPort(IOPORT1) & BOTH_BUTTONS) == BOTH_BUTTONS) {
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
// chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
// }
/*
* Normal main() thread activity, in this demo it does nothing except
@ -93,10 +95,10 @@ int main(void) {
* or print "Hello World!" on serial driver 1.
*/
while (TRUE) {
if (!palReadPad(IOPORT1, PA_BUTTON1))
sdWrite(&SD1, (uint8_t *)"Hello World!\r\n", 14);
if (!palReadPad(IOPORT1, PA_BUTTON2))
TestThread(&SD1);
// if (!palReadPad(IOPORT1, PA_BUTTON1))
// sdWrite(&SD1, (uint8_t *)"Hello World!\r\n", 14);
// if (!palReadPad(IOPORT1, PA_BUTTON2))
// TestThread(&SD1);
chThdSleepMilliseconds(500);
}
return 0;

View File

@ -146,7 +146,7 @@ bssloop:
ldr r1, =_main_exit_handler
bx r1
.code 32
#else /* !defined(THUMB_NO_INTERWORKING)
#else /* !defined(THUMB_NO_INTERWORKING) */
bl main
b _main_exit_handler
#endif /* !defined(THUMB_NO_INTERWORKING) */
@ -172,7 +172,6 @@ _main_exit_handler:
__early_init:
bx lr
.code 32
#endif
/*
* Default late initialization code. It is declared weak in order to be
@ -188,6 +187,7 @@ __early_init:
__late_init:
bx lr
.code 32
#endif
#endif /* !defined(__DOXYGEN__) */
/** @} */

View File

@ -26,6 +26,9 @@
* @{
*/
#define __FROM_ASM__
#include "armparams.h"
#if !defined(__DOXYGEN__)
.section irq
@ -39,7 +42,8 @@
.global IrqHandler
IrqHandler:
stmfd sp!, {r0-r3, r12, lr}
ldr r0, [pc, #ARM_IRQ_REGISTER_OFFSET]
ldr r0, =ARM_IRQ_VECTOR_REG
ldr r0, [r0]
ldr lr, =_port_irq_common
bx r0

View File

@ -37,9 +37,10 @@ SECTIONS
. = 0;
_text = .;
startup : ALIGN(16) SUBALIGN(16)
boot : ALIGN(16) SUBALIGN(16)
{
KEEP(*(vectors))
KEEP(*(irq))
} > flash
constructors : ALIGN(4) SUBALIGN(4)

View File

@ -35,7 +35,7 @@
/**
* @brief ARM core model.
*/
#define ARM_MODEL ARM_MODEL_ARM7TDMI
#define ARM_CORE ARM_CORE_ARM7TDMI
/**
* @brief Thumb-capable.
@ -52,14 +52,10 @@
*/
#define ARM_WFI_IMPL (PCON = 1)
/* The following code is not processed when the file is included from an
asm module.*/
#if !defined(_FROM_ASM_)
/* Including the device header.*/
#include "lpc214x.h"
#endif /* !defined(_FROM_ASM_) */
/**
* @brief Address of the IRQ vector register in the interrupt controller.
*/
#define ARM_IRQ_VECTOR_REG 0xFFFFF030
#endif /* _ARMPARAMS_H_ */

View File

@ -42,6 +42,11 @@
*/
#define PORT_ARCHITECTURE_ARM
/* The following code is not processed when the file is included from an
asm module because those intrinsic macros are not necessarily defined
by the assembler too.*/
#if !defined(_FROM_ASM_)
/**
* @brief Compiler name and version.
*/
@ -127,13 +132,13 @@
/* ARM core check.*/
#if (ARM_CORE == ARM_CORE_ARM7TDMI) || defined(__DOXYGEN__)
#define PORT_ARCHITECTURE_ARM_ARM7
#define PORT_ARCHITECTURE_NAME "ARM7"
#define PORT_CORE_VARIANT_NAME "ARMv4"
#define PORT_ARCHITECTURE_NAME "ARMv4T"
#define PORT_CORE_VARIANT_NAME "ARM7"
#elif ARM_CORE == ARM_CORE_ARM9
#define PORT_ARCHITECTURE_ARM_ARM9
#define PORT_ARCHITECTURE_NAME "ARM9"
#define PORT_CORE_VARIANT_NAME "ARMv5"
#define PORT_ARCHITECTURE_NAME "ARMv5T"
#define PORT_CORE_VARIANT_NAME "ARM9"
#elif ARM_CORE == ARM_CORE_CORTEX_A8
#define PORT_ARCHITECTURE_ARM_CORTEXA8
@ -185,9 +190,9 @@ typedef uint16_t systime_t;
typedef uint64_t stkalign_t;
/**
* @brief Generic PPC register.
* @brief Generic ARM register.
*/
typedef void *regppc_t;
typedef void *regarm_t;
/**
* @brief Interrupt saved context.
@ -195,14 +200,14 @@ typedef void *regppc_t;
* interrupt handler.
*/
struct port_extctx {
regarm_t spsr_irq;
regarm_t lr_irq;
regarm_t r0;
regarm_t r1;
regarm_t r2;
regarm_t r3;
regarm_t r12;
regarm_t lr_usr;
regarm_t spsr_irq;
regarm_t lr_irq;
regarm_t r0;
regarm_t r1;
regarm_t r2;
regarm_t r3;
regarm_t r12;
regarm_t lr_usr;
};
/**
@ -211,15 +216,15 @@ struct port_extctx {
* switch.
*/
struct port_intctx {
regarm_t r4;
regarm_t r5;
regarm_t r6;
regarm_t r7;
regarm_t r8;
regarm_t r9;
regarm_t r10;
regarm_t r11;
regarm_t lr;
regarm_t r4;
regarm_t r5;
regarm_t r6;
regarm_t r7;
regarm_t r8;
regarm_t r9;
regarm_t r10;
regarm_t r11;
regarm_t lr;
};
/**
@ -228,12 +233,10 @@ struct port_intctx {
* @p port_intctx structure representing the stack pointer
* at context switch time.
*/
struct port_context {
struct intctx *r13;
struct context {
struct port_intctx *r13;
};
#endif /* !defined(_FROM_ASM_) */
/*===========================================================================*/
/* Module macros. */
/*===========================================================================*/
@ -336,9 +339,9 @@ struct port_context {
extern "C" {
#endif
#ifdef THUMB
void _port_switch_thumb(Thread *ntp, Thread *otp);
void _port_switch_thumb(thread_t *ntp, thread_t *otp);
#else
void _port_switch_arm(Thread *ntp, Thread *otp);
void _port_switch_arm(thread_t *ntp, thread_t *otp);
#endif
void _port_thread_start(void);
#ifdef __cplusplus

View File

@ -0,0 +1,125 @@
/*
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
2011,2012,2013 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/>.
*/
/**
* @file chcore_timer.h
* @brief System timer header file.
*
* @addtogroup ARM_TIMER
* @{
*/
#ifndef _CHCORE_TIMER_H_
#define _CHCORE_TIMER_H_
/* This is the only header in the HAL designed to be include-able alone.*/
#include "st.h"
/*===========================================================================*/
/* Module constants. */
/*===========================================================================*/
/*===========================================================================*/
/* Module pre-compile time settings. */
/*===========================================================================*/
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/*===========================================================================*/
/* Module data structures and types. */
/*===========================================================================*/
/*===========================================================================*/
/* Module macros. */
/*===========================================================================*/
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
/*===========================================================================*/
/* Module inline functions. */
/*===========================================================================*/
/**
* @brief Starts the alarm.
* @note Makes sure that no spurious alarms are triggered after
* this call.
*
* @param[in] time the time to be set for the first alarm
*
* @notapi
*/
static inline void port_timer_start_alarm(systime_t time) {
stStartAlarm(time);
}
/**
* @brief Stops the alarm interrupt.
*
* @notapi
*/
static inline void port_timer_stop_alarm(void) {
stStopAlarm();
}
/**
* @brief Sets the alarm time.
*
* @param[in] time the time to be set for the next alarm
*
* @notapi
*/
static inline void port_timer_set_alarm(systime_t time) {
stSetAlarm(time);
}
/**
* @brief Returns the system time.
*
* @return The system time.
*
* @notapi
*/
static inline systime_t port_timer_get_time(void) {
return stGetCounter();
}
/**
* @brief Returns the current alarm time.
*
* @return The currently set alarm time.
*
* @notapi
*/
static inline systime_t port_timer_get_alarm(void) {
return stGetAlarm();
}
#endif /* _CHCORE_TIMER_H_ */
/** @} */

View File

@ -0,0 +1,111 @@
/*
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
2011,2012,2013 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/>.
*/
/**
* @file ARM/compilers/GCC/chtypes.h
* @brief ARM port system types.
*
* @addtogroup ARM_GCC_CORE
* @{
*/
#ifndef _CHTYPES_H_
#define _CHTYPES_H_
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
/**
* @name Common constants
*/
/**
* @brief Generic 'false' boolean constant.
*/
#if !defined(FALSE) || defined(__DOXYGEN__)
#define FALSE 0
#endif
/**
* @brief Generic 'true' boolean constant.
*/
#if !defined(TRUE) || defined(__DOXYGEN__)
#define TRUE (!FALSE)
#endif
/** @} */
/**
* @name Derived generic types
* @{
*/
typedef volatile int8_t vint8_t; /**< Volatile signed 8 bits. */
typedef volatile uint8_t vuint8_t; /**< Volatile unsigned 8 bits. */
typedef volatile int16_t vint16_t; /**< Volatile signed 16 bits. */
typedef volatile uint16_t vuint16_t; /**< Volatile unsigned 16 bits. */
typedef volatile int32_t vint32_t; /**< Volatile signed 32 bits. */
typedef volatile uint32_t vuint32_t; /**< Volatile unsigned 32 bits. */
/** @} */
/**
* @name Kernel types
* @{
*/
typedef uint32_t rtcnt_t; /**< Realtime counter. */
typedef uint64_t rttime_t; /**< Realtime accumulator. */
typedef uint32_t syssts_t; /**< System status word. */
typedef uint8_t tmode_t; /**< Thread flags. */
typedef uint8_t tstate_t; /**< Thread state. */
typedef uint8_t trefs_t; /**< Thread references counter. */
typedef uint8_t tslices_t; /**< Thread time slices counter.*/
typedef uint32_t tprio_t; /**< Thread priority. */
typedef int32_t msg_t; /**< Inter-thread message. */
typedef int32_t eventid_t; /**< Numeric event identifier. */
typedef uint32_t eventmask_t; /**< Mask of event identifiers. */
typedef uint32_t eventflags_t; /**< Mask of event flags. */
typedef int32_t cnt_t; /**< Generic signed counter. */
typedef uint32_t ucnt_t; /**< Generic unsigned counter. */
/** @} */
/**
* @brief ROM constant modifier.
* @note It is set to use the "const" keyword in this port.
*/
#define ROMCONST const
/**
* @brief Makes functions not inlineable.
* @note If the compiler does not support such attribute then the
* realtime counter precision could be degraded.
*/
#define NOINLINE __attribute__((noinline))
/**
* @brief Optimized thread function declaration macro.
*/
#define PORT_THD_FUNCTION(tname, arg) msg_t tname(void *arg)
/**
* @brief Packed variable specifier.
*/
#define PACKED_VAR __attribute__((packed))
#endif /* _CHTYPES_H_ */
/** @} */