aboutsummaryrefslogtreecommitdiffstats
path: root/ports/AVR
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-01-18 17:09:11 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-01-18 17:09:11 +0000
commit0c36565550f5b81e6b853ebf3e0b323ed4a8f1f2 (patch)
tree0f85c364dc506704222f4dcaceadf79430d4cf6b /ports/AVR
parentcb692f1c51bb79c7c6f015cef9da5dfeb1bfebba (diff)
downloadChibiOS-0c36565550f5b81e6b853ebf3e0b323ed4a8f1f2.tar.gz
ChibiOS-0c36565550f5b81e6b853ebf3e0b323ed4a8f1f2.tar.bz2
ChibiOS-0c36565550f5b81e6b853ebf3e0b323ed4a8f1f2.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@637 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'ports/AVR')
-rw-r--r--ports/AVR/chcore.c21
-rw-r--r--ports/AVR/chcore.h55
-rw-r--r--ports/AVR/port.dox65
3 files changed, 109 insertions, 32 deletions
diff --git a/ports/AVR/chcore.c b/ports/AVR/chcore.c
index 9ae0b4c56..ee35f3459 100644
--- a/ports/AVR/chcore.c
+++ b/ports/AVR/chcore.c
@@ -24,13 +24,6 @@
#include <ch.h>
-/*
- * This file is a template of the system driver functions provided by a port.
- * Some of the following functions may be implemented as macros in chcore.h if
- * the implementer decides that there is an advantage in doing so, as example
- * because performance concerns.
- */
-
/**
* The default implementation of this function is void so no messages are
* actually printed.
@@ -38,8 +31,10 @@
* it in your application code.
* @param msg pointer to the message string
*/
+/** @cond never */
__attribute__((weak))
-void sys_puts(char *msg) {
+/** @endcond */
+void port_puts(char *msg) {
}
/**
@@ -49,8 +44,10 @@ void sys_puts(char *msg) {
* @note The function is declared as a weak symbol, it is possible to redefine
* it in your application code.
*/
+/** @cond never */
__attribute__((naked, weak))
-void sys_switch(Thread *otp, Thread *ntp) {
+/** @endcond */
+void port_switch(Thread *otp, Thread *ntp) {
asm volatile ("push r2");
asm volatile ("push r3");
@@ -113,10 +110,12 @@ void sys_switch(Thread *otp, Thread *ntp) {
* @note The function is declared as a weak symbol, it is possible to redefine
* it in your application code.
*/
+/** @cond never */
__attribute__((weak))
-void sys_halt(void) {
+/** @endcond */
+void port_halt(void) {
- sys_disable();
+ port_disable();
while (TRUE) {
}
}
diff --git a/ports/AVR/chcore.h b/ports/AVR/chcore.h
index 34eba546c..a03e58acc 100644
--- a/ports/AVR/chcore.h
+++ b/ports/AVR/chcore.h
@@ -165,10 +165,10 @@ typedef struct {
/**
* IRQ prologue code, inserted at the start of all IRQ handlers enabled to
* invoke system APIs.
- * This code tricks the compiler to save the specified registers by "touching"
- * them.
+ * This code tricks the compiler to save all the specified registers by
+ * "touching" them.
*/
-#define SYS_IRQ_PROLOGUE() { \
+#define PORT_IRQ_PROLOGUE() { \
asm ("" : : : "r18", "r19", "r20", "r21", "r22", "r23", "r24", \
"r25", "r26", "r27", "r30", "r31"); \
}
@@ -177,7 +177,7 @@ asm ("" : : : "r18", "r19", "r20", "r21", "r22", "r23", "r24", \
* IRQ epilogue code, inserted at the end of all IRQ handlers enabled to
* invoke system APIs.
*/
-#define SYS_IRQ_EPILOGUE() { \
+#define PORT_IRQ_EPILOGUE() { \
if (chSchRescRequiredI()) \
chSchDoRescheduleI(); \
}
@@ -186,53 +186,66 @@ asm ("" : : : "r18", "r19", "r20", "r21", "r22", "r23", "r24", \
* IRQ handler function modifier. Note, it just aliases the WinAVR "ISR"
* macro.
*/
-#define SYS_IRQ_HANDLER ISR
+#define PORT_IRQ_HANDLER ISR
/**
- * This port function is implemented as inlined code for performance reasons.
+ * This function is empty in this port.
*/
-#define sys_disable() asm volatile ("cli")
+#define port_init()
/**
- * This port function is implemented as inlined code for performance reasons.
+ * Implemented as global interrupt disable.
+ */
+#define port_lock() asm volatile ("cli")
+
+/**
+ * Implemented as global interrupt enable.
*/
-#define sys_enable() asm volatile ("sei")
+#define port_unlock() asm volatile ("sei")
/**
* This function is empty in this port.
*/
-#define sys_disable_from_isr()
+#define port_lock_from_isr()
/**
* This function is empty in this port.
*/
-#define sys_enable_from_isr()
+#define port_unlock_from_isr()
+
+/**
+ * Implemented as global interrupt disable.
+ */
+#define port_disable() asm volatile ("cli")
+
+/**
+ * Same as @p port_disable() in this port, there is no difference between the
+ * two states.
+ */
+#define port_suspend() asm volatile ("cli")
/**
- * Disables all the interrupt sources, even those having a priority higher
- * to the kernel.
- * In this port it is no different than sys_disable() because the simple
- * interrupt handling
+ * Implemented as global interrupt enable.
*/
-#define sys_disable_all() sys_disable()
+#define port_enable() asm volatile ("sei")
/**
* This port function is implemented as inlined code for performance reasons.
*/
#if ENABLE_WFI_IDLE != 0
-#define sys_wait_for_interrupt() { \
+#define port_wait_for_interrupt() { \
asm volatile ("sleep"); \
}
#else
-#define sys_wait_for_interrupt()
+#define port_wait_for_interrupt()
#endif
#ifdef __cplusplus
extern "C" {
#endif
- void sys_puts(char *msg);
- void sys_switch(Thread *otp, Thread *ntp);
- void sys_halt(void);
+ void port_puts(char *msg);
+ void port_switch(Thread *otp, Thread *ntp);
+ void port_halt(void);
void threadstart(void);
#ifdef __cplusplus
}
diff --git a/ports/AVR/port.dox b/ports/AVR/port.dox
new file mode 100644
index 000000000..2a789c5e4
--- /dev/null
+++ b/ports/AVR/port.dox
@@ -0,0 +1,65 @@
+/**
+ * @defgroup AVR MegaAVR
+ * @{
+ * @details AVR port details. This section how the ChibiOS/RT features are
+ * implemented on this architecture.
+ *
+ * @section AVR_STATES Mapping of the System States in the AVR port
+ * The ChibiOS/RT logical @ref system_states are mapped as follow in the AVR
+ * port:
+ * - <b>Initialization</b>. This state is represented by the startup code and
+ * the initialization code before @p chSysInit() is executed. It has not a
+ * special hardware state associated.
+ * - <b>Normal</b>. This is the state the system has after executing
+ * @p chSysInit(). Interrupts are enabled.
+ * - <b>Suspended</b>. Interrupts are disabled.
+ * - <b>Disabled</b>. Interrupts are enabled. This state is equivalent to the
+ * Suspended state because there are no fast interrupts in this architecture.
+ * - <b>Sleep</b>. This state is entered with the execution of the specific
+ * instruction @p <b>sleep</b>.
+ * - <b>S-Locked</b>. Interrupts are disabled.
+ * - <b>I-Locked</b>. This state is equivalent to the SRI state, the
+ * @p chSysLockI() and @p chSysUnlockI() APIs do nothing (still use them in
+ * order to formally change state because this may change).
+ * - <b>Serving Regular Interrupt</b>. Normal interrupt service code.
+ * - <b>Serving Fast Interrupt</b>. Not present in this architecture.
+ * - <b>Serving Non-Maskable Interrupt</b>. Not present in this architecture.
+ * - <b>Halted</b>. Implemented as an infinite loop with interrupts disabled.
+ *
+ * @section AVR_NOTES The AVR port notes
+ * - The AVR does not have a dedicated interrupt stack, make sure to reserve
+ * enough stack space for interrupts in each thread stack. This can be done
+ * by modifying the @p INT_REQUIRED_STACK macro into
+ * <b>./ports/AVR/chcore.h</b>.
+ *
+ * @ingroup Ports
+ */
+/** @} */
+
+/**
+ * @defgroup AVR_CONF Configuration Options
+ * @{
+ * @brief AVR Configuration Options.
+ * The AVR port allows some architecture-specific configurations settings
+ * that can be specified externally, as example on the compiler command line:
+ * - @p INT_REQUIRED_STACK, this value represent the amount of stack space
+ * used by the interrupt handlers.<br>
+ * The default for this value is @p 32, this space is allocated for each
+ * thread so be careful in order to not waste precious RAM space.<br>
+ * The default value is set into <b>./ports/AVR/chcore.h</b>.
+ *
+ * @ingroup AVR
+ */
+/** @} */
+
+/**
+ * @defgroup AVR_CORE AVR Core Implementation
+ * @{
+ * @brief AVR specific port code, structures and macros.
+ *
+ * @ingroup AVR
+ * @file ports/AVR/chtypes.h Port types.
+ * @file ports/AVR/chcore.h Port related structures and macros.
+ * @file ports/AVR/chcore.c Port related code.
+ */
+/** @} */