diff options
28 files changed, 527 insertions, 205 deletions
diff --git a/demos/STM8S-STM8S208-RC/ch.rapp b/demos/STM8S-STM8S208-RC/ch.rapp index 3f90dd82b..d9da5716d 100644 --- a/demos/STM8S-STM8S208-RC/ch.rapp +++ b/demos/STM8S-STM8S208-RC/ch.rapp @@ -10,15 +10,15 @@ <Set Header="RCST7" >
<Section Header="Model" >
<Property Header="GlobalMemory" Value="" Removable="1" />
-
+
</Section>
-
+
</Set>
-
+
</Config>
-
+
</Options>
-
+
</NodeC>
<NodeC Path="..\..\os\kernel\src\chlists.c" Header="chlists.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chlists.obj" sate="0" />
<NodeC Path="..\..\os\kernel\src\chmboxes.c" Header="chmboxes.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chmboxes.obj" sate="0" />
@@ -34,15 +34,15 @@ <Set Header="RCST7" >
<Section Header="Model" >
<Property Header="GlobalMemory" Value="" Removable="1" />
-
+
</Section>
-
+
</Set>
-
+
</Config>
-
+
</Options>
-
+
</NodeC>
<NodeC Path="..\..\os\kernel\src\chsem.c" Header="chsem.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chsem.obj" sate="0" />
<NodeC Path="..\..\os\kernel\src\chsys.c" Header="chsys.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chsys.obj" sate="0" />
@@ -53,17 +53,17 @@ <Set Header="RCST7" >
<Section Header="Model" >
<Property Header="GlobalMemory" Value="" Removable="1" />
-
+
</Section>
-
+
</Set>
-
+
</Config>
-
+
</Options>
-
+
</NodeC>
-
+
</Group>
<Group Header="test" Marker="-1" OutputFile="" sate="0" >
<NodeC Path="..\..\test\test.c" Header="test.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\test.obj" sate="0" />
@@ -78,11 +78,11 @@ <NodeC Path="..\..\test\testqueues.c" Header="testqueues.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\testqueues.obj" sate="0" />
<NodeC Path="..\..\test\testsem.c" Header="testsem.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\testsem.obj" sate="0" />
<NodeC Path="..\..\test\testthd.c" Header="testthd.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\testthd.obj" sate="0" />
-
+
</Group>
<Group Header="port" Marker="-1" OutputFile="" sate="0" >
<NodeC Path="..\..\os\ports\RC\STM8\chcore.c" Header="chcore.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chcore.obj" sate="0" />
-
+
</Group>
<Group Header="hal" Marker="-1" OutputFile="" sate="0" >
<NodeC Path="..\..\os\hal\src\adc.c" Header="adc.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\adc.obj" sate="0" />
@@ -97,11 +97,11 @@ <NodeC Path="..\..\os\hal\platforms\STM8\hal_lld.c" Header="hal_lld.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\hal_lld.obj" sate="0" />
<NodeC Path="..\..\os\hal\platforms\STM8\serial_lld.c" Header="serial_lld.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\serial_lld.obj" sate="0" />
<NodeC Path="..\..\os\hal\platforms\STM8\pal_lld.c" Header="pal_lld.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\pal_lld.obj" sate="0" />
-
+
</Group>
<Group Header="board" Marker="-1" OutputFile="" sate="0" >
<NodeC Path="..\..\boards\RAISONANCE_REVA_STM8S\board.c" Header="board.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\board.obj" sate="0" />
-
+
</Group>
<NodeC Path=".\main.c" Header="main.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\main.obj" sate="0" />
<Options>
@@ -109,21 +109,21 @@ <Set Header="ApplicationBuild" >
<Section Header="General" >
<Property Header="TargetFamily" Value="ST7" />
-
+
</Section>
<Section Header="Directories" >
<Property Header="IncDir" Value="$(RkitInc);$(RkitInc)\ST7;..\..\os\kernel\include;..\..\os\ports\RC\STM8;..\..\os\hal\include;..\..\os\hal\platforms\STM8;..\..\boards\RAISONANCE_REVA_STM8S;..\..\test" Removable="1" />
<Property Header="OutDir" Value="$(ApplicationDir)/bin" Removable="1" />
<Property Header="ListDir" Value="$(ApplicationDir)/lst" Removable="1" />
<Property Header="LinkerOutputDir" Value="Output Directory" Removable="1" />
-
+
</Section>
-
+
</Set>
<Set Header="Target" >
<Section Header="ProcessorST7" >
<Property Header="Processor" Value="STM8S208MB" Removable="1" />
-
+
</Section>
<Section Header="ToolSetST7" >
<Property Header="BuildToolSetST7" Value="ST7\RaisonanceTools.config" Removable="1" />
@@ -134,33 +134,33 @@ <Section Header="DebugST7" >
<Property Header="Startup" Value="1" Removable="1" />
<Property Header="DebugTool_STM8" Value="RLINK_STM8" Removable="1" />
-
+
</Section>
</Set>
<Set Header="RCST7" >
<Section Header="CodeGen" >
<Property Header="ENUMTYPE" Value="ET(CHAR)" Removable="1" />
-
+
</Section>
<Section Header="Model" >
<Property Header="GlobalMemory" Value="DGC(DATA)" Removable="1" />
<Property Header="ModelP" Value="STM8(SMALL)" Removable="1" />
-
+
</Section>
<Section Header="OPTIM" >
<Property Header="OTLEVEL" Value="3" Removable="1" />
<Property Header="SPEEDSIZE" Value="SPEED" Removable="1" />
-
+
</Section>
-
+
</Set>
<Set Header="MAST7" >
<Section Header="Set" >
<Property Header="Defines" Value="STM8S208RB" Removable="1" />
-
+
</Section>
-
+
</Set>
</Config>
</Options>
diff --git a/docs/src/articles.dox b/docs/src/articles.dox index f6f02e811..5aff3203e 100644 --- a/docs/src/articles.dox +++ b/docs/src/articles.dox @@ -22,6 +22,7 @@ * ChibiOS/RT Articles and Code Examples:
* - @subpage article_eclipse
* - @subpage article_eclipse2
+ * - @subpage article_debug
* - @subpage article_create_thread
* - @subpage article_interrupts
* - @subpage article_wakeup
diff --git a/docs/src/debug.dox b/docs/src/debug.dox new file mode 100644 index 000000000..46a67dfb2 --- /dev/null +++ b/docs/src/debug.dox @@ -0,0 +1,138 @@ +/*
+ 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/>.
+*/
+
+/**
+ * @page article_debug Debugging ChibiOS/RT applications
+ * ChibiOS/RT offers several mechanisms that can help in the debug phase of
+ * the development cycle.
+ *
+ * <h2>What this guide does not cover</h2>
+ * This guide assumes knowledge in following areas:
+ * - General knowledge of embedded development.
+ * - RTOS concepts.
+ * - Setup of your specific target hardware and toolchain.
+ * - Knowledge of your toolchain. The guide will explain what you need to do,
+ * not how it is done using you specific debugger, compiler, JTAG probe and
+ * target hardware.
+ * .
+ * <h2>Helpful debugging configuration settings</h2>
+ * There are several settings in your kernel configuration file
+ * (see @ref templates/chconf.h) that you may want to enable during
+ * debugging and in general during the whole development process.
+ * - @p CH_OPTIMIZE_SPEED=FALSE, this disables inlining into the kernel code
+ * and makes it easier to debug using your debugger, you may also want
+ * to reduce or disable compiler optimizations (-O0 using GCC).
+ * - @p CH_DBG_ENABLE_CHECKS=TRUE, this setting enables the checks on the
+ * API parameters, useful to understand if you are passing wrong parameters
+ * to the OS functions.
+ * - @p CH_DBG_ENABLE_ASSERTS=TRUE, this setting enables the OS internal
+ * consistency checks, this can trap several kind of errors in the user
+ * code (or in the kernel itself).
+ * - @p CH_DBG_ENABLE_STACK_CHECK=TRUE, this setting enables checks on
+ * threads stack overflow. Note that this option is not available in
+ * all ports, check your port documentation. If not supported then it
+ * is silently ignored, see also the article @ref article_stacks.
+ * - @p CH_DBG_FILL_THREADS=TRUE, this setting enables the threads workspace
+ * filling, this can help examining the stack usage from your debugger.
+ * .
+ * Note that all the failed checks lock the kernel into the @p port_halt()
+ * function. In order to assess what triggered the lock the global variable
+ * @p panic_msg must be inspected using the debugger, the variable is a
+ * pointer to an error message (a zero terminated string), the pointer may
+ * contain @p NULL if the lock was triggered by a stack overflow.
+ *
+ * <h2>Common errors and symptoms</h2>
+ * There are some common errors while using an RTOS, use the following
+ * table as a check list, if your problem is not a generic programming error
+ * then probably it is one of the following common RTOS/embedded related
+ * mistakes:
+ * - Insufficient stack allocated to one or more threads.<br>
+ * Common symptoms:
+ * - Target instability.
+ * - Target locked into the @p port_halt() function.
+ * - Target trapped into an exception handler (architecture dependent).
+ * - Target apparent self reset (not real resets usually).
+ * .
+ * - Insufficient stack allocated to the IRQ stack (in those architectures
+ * that have a separate IRQ stack, ARM as example).<br>
+ * Common symptoms:
+ * - Target instability.
+ * - Target trapped into an exception handler (architecture dependent).
+ * - Target apparent self reset (not real resets usually).
+ * .
+ * - Use of a non reentrant function from within an interrupt handler, as
+ * example most C runtime functions.<br>
+ * Common symptoms:
+ * - Target instability.
+ * - Unexpected application behavior.
+ * .
+ * - Missing use of a mutual exclusion mechanism to protect data
+ * (or non reentrant code) shared among multiple threads and/or
+ * threads and interrupt handlers, see also the article
+ * @ref article_mutual_exclusion.<br>
+ * Common symptoms:
+ * - Target instability.
+ * - Unexpected application behavior.
+ * .
+ * - Use of S-class or I-class APIs outside a proper lock state, see the
+ * @ref concepts article, specifically the @ref api_suffixes and
+ * @ref system_states sections.<br>
+ * Common symptoms:
+ * - Target instability.
+ * - Target trapped into an exception handler (architecture dependent).
+ * - Target apparent self reset (not real resets usually).
+ * .
+ * - Use of a non I-class API from an interrupt handler, see the
+ * @ref concepts article, specifically the @ref api_suffixes and
+ * @ref system_states sections.<br>
+ * Common symptoms:
+ * - Target instability.
+ * - Target trapped into an exception handler (architecture dependent).
+ * - Target apparent self reset (not real resets usually).
+ * .
+ * - Wrong threads priority assignment. One of the most critical things
+ * to do when designing an RTOS based application is to assign correct
+ * priorities to the threads in the system.<br>
+ * Common symptoms:
+ * - Excessive or unpredictable response times.
+ * - Threads that appear to be never executed (CPU intensive threads at
+ * higher priority).
+ * .
+ * .
+ * <h2>General suggestions</h2>
+ * For the less expert users, there are several things you may do in order
+ * to minimize the need for debugging:
+ * - Read carefully the documentation first.
+ * - Try to find a code examples for things are you going to do, good sources
+ * are: the documentation, the test code, under "./test" you will
+ * find examples for almost any API in the ChibiOS/RT kernel and most
+ * common RTOS related tasks, under "./testhal" there are examples
+ * regarding the various device drivers, the various demos contain
+ * good code samples too).
+ * - Start your application from an existing demos, add things one piece at
+ * time and test often, if you add too many things at once a small problem
+ * can become a debugging nightmare. Follow the cycle: think, implement,
+ * test, repeat.
+ * - If you are stuck for too much time then consider asking for advice.
+ * - Report bugs and problems, bugs can be fixed, problems can become new
+ * articles in the documentation (this and other documentation articles
+ * spawned from questions in the forum or in the tracker).
+ * - Never give up :-)
+ * .
+ */
diff --git a/os/hal/platforms/AVR/serial_lld.c b/os/hal/platforms/AVR/serial_lld.c index 48f688b64..8512fb873 100644 --- a/os/hal/platforms/AVR/serial_lld.c +++ b/os/hal/platforms/AVR/serial_lld.c @@ -18,8 +18,9 @@ */
/**
- * @file AVR/serial_lld.c
- * @brief AVR low level serial driver code.
+ * @file AVR/serial_lld.c
+ * @brief AVR low level serial driver code.
+ *
* @addtogroup AVR_SERIAL
* @{
*/
@@ -34,18 +35,18 @@ /*===========================================================================*/
/**
- * @brief USART0 serial driver identifier.
- * @note The name does not follow the convention used in the other ports
- * (COMn) because a name conflict with the AVR headers.
+ * @brief USART0 serial driver identifier.
+ * @note The name does not follow the convention used in the other ports
+ * (COMn) because a name conflict with the AVR headers.
*/
#if USE_AVR_USART0 || defined(__DOXYGEN__)
SerialDriver SD1;
#endif
/**
- * @brief USART1 serial driver identifier.
- * @note The name does not follow the convention used in the other ports
- * (COMn) because a name conflict with the AVR headers.
+ * @brief USART1 serial driver identifier.
+ * @note The name does not follow the convention used in the other ports
+ * (COMn) because a name conflict with the AVR headers.
*/
#if USE_AVR_USART1 || defined(__DOXYGEN__)
SerialDriver SD2;
@@ -56,7 +57,7 @@ SerialDriver SD2; /*===========================================================================*/
/**
- * @brief Driver default configuration.
+ * @brief Driver default configuration.
*/
static const SerialConfig default_config = {
UBRR(SERIAL_DEFAULT_BITRATE),
@@ -88,8 +89,9 @@ static void notify1(void) { }
/**
- * @brief USART0 initialization.
- * @param[in] config the architecture-dependent serial driver configuration
+ * @brief USART0 initialization.
+ *
+ * @param[in] config the architecture-dependent serial driver configuration
*/
static void usart0_init(const SerialConfig *config) {
@@ -101,7 +103,7 @@ static void usart0_init(const SerialConfig *config) { }
/**
- * @brief USART0 de-initialization.
+ * @brief USART0 de-initialization.
*/
static void usart0_deinit(void) {
@@ -118,8 +120,9 @@ static void notify2(void) { }
/**
- * @brief USART1 initialization.
- * @param[in] config the architecture-dependent serial driver configuration
+ * @brief USART1 initialization.
+ *
+ * @param[in] config the architecture-dependent serial driver configuration
*/
static void usart1_init(const SerialConfig *config) {
@@ -131,7 +134,7 @@ static void usart1_init(const SerialConfig *config) { }
/**
- * @brief USART1 de-initialization.
+ * @brief USART1 de-initialization.
*/
static void usart1_deinit(void) {
@@ -216,7 +219,7 @@ CH_IRQ_HANDLER(USART1_UDRE_vect) { /*===========================================================================*/
/**
- * Low level serial driver initialization.
+ * @brief Low level serial driver initialization.
*/
void sd_lld_init(void) {
@@ -229,35 +232,38 @@ void sd_lld_init(void) { }
/**
- * @brief Low level serial driver configuration and (re)start.
+ * @brief Low level serial driver configuration and (re)start.
*
- * @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] config the architecture-dependent serial driver configuration.
+ * If this parameter is set to @p NULL then a default
+ * configuration is used.
*/
-void sd_lld_start(SerialDriver *sdp) {
+void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
- if (sdp->config == NULL)
- sdp->config = &default_config;
+ if (config == NULL)
+ config = &default_config;
#if USE_AVR_USART0
if (&SD1 == sdp) {
- usart0_init(sdp->config);
+ usart0_init(config);
return;
}
#endif
#if USE_AVR_USART1
if (&SD2 == sdp) {
- usart1_init(sdp->config);
+ usart1_init(config);
return;
}
#endif
}
/**
- * @brief Low level serial driver stop.
+ * @brief Low level serial driver stop.
* @details De-initializes the USART, stops the associated clock, resets the
* interrupt vector.
*
- * @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] sdp pointer to a @p SerialDriver object
*/
void sd_lld_stop(SerialDriver *sdp) {
diff --git a/os/hal/platforms/AVR/serial_lld.h b/os/hal/platforms/AVR/serial_lld.h index b89bd3ef3..604a46c99 100644 --- a/os/hal/platforms/AVR/serial_lld.h +++ b/os/hal/platforms/AVR/serial_lld.h @@ -18,8 +18,9 @@ */
/**
- * @file AVR/serial_lld.h
- * @brief AVR low level serial driver header.
+ * @file AVR/serial_lld.h
+ * @brief AVR low level serial driver header.
+ *
* @addtogroup AVR_SERIAL
* @{
*/
@@ -38,18 +39,18 @@ /*===========================================================================*/
/**
- * @brief USART0 driver enable switch.
+ * @brief USART0 driver enable switch.
* @details If set to @p TRUE the support for USART0 is included.
- * @note The default is @p FALSE.
+ * @note The default is @p FALSE.
*/
#if !defined(USE_AVR_USART0) || defined(__DOXYGEN__)
#define USE_AVR_USART0 TRUE
#endif
/**
- * @brief USART1 driver enable switch.
+ * @brief USART1 driver enable switch.
* @details If set to @p TRUE the support for USART1 is included.
- * @note The default is @p TRUE.
+ * @note The default is @p TRUE.
*/
#if !defined(USE_AVR_USART1) || defined(__DOXYGEN__)
#define USE_AVR_USART1 TRUE
@@ -64,12 +65,12 @@ /*===========================================================================*/
/**
- * @brief Serial Driver condition flags type.
+ * @brief Serial Driver condition flags type.
*/
typedef uint8_t sdflags_t;
/**
- * @brief AVR Serial Driver configuration structure.
+ * @brief AVR Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
*/
@@ -85,14 +86,12 @@ typedef struct { } SerialConfig;
/**
- * @brief @p SerialDriver specific data.
+ * @brief @p SerialDriver specific data.
*/
#define _serial_driver_data \
_base_asynchronous_channel_data \
/* Driver state.*/ \
sdstate_t state; \
- /* Current configuration data.*/ \
- const SerialConfig *config; \
/* Input queue.*/ \
InputQueue iqueue; \
/* Output queue.*/ \
@@ -112,8 +111,8 @@ typedef struct { /*===========================================================================*/
/**
- * @brief Macro for baud rate computation.
- * @note Make sure the final baud rate is within tolerance.
+ * @brief Macro for baud rate computation.
+ * @note Make sure the final baud rate is within tolerance.
*/
#define UBRR(b) ((F_CPU / (b << 4)) - 1)
@@ -132,7 +131,7 @@ extern SerialDriver SD2; extern "C" {
#endif
void sd_lld_init(void);
- void sd_lld_start(SerialDriver *sdp);
+ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
void sd_lld_stop(SerialDriver *sdp);
#ifdef __cplusplus
}
diff --git a/os/hal/platforms/LPC11xx/serial_lld.c b/os/hal/platforms/LPC11xx/serial_lld.c index cc6146c3c..2cff76cd6 100644 --- a/os/hal/platforms/LPC11xx/serial_lld.c +++ b/os/hal/platforms/LPC11xx/serial_lld.c @@ -58,16 +58,17 @@ static const SerialConfig default_config = { * @brief UART initialization.
*
* @param[in] sdp communication channel associated to the UART
+ * @param[in] config the architecture-dependent serial driver configuration
*/
-static void uart_init(SerialDriver *sdp) {
+static void uart_init(SerialDriver *sdp, const SerialConfig *config) {
LPC_UART_TypeDef *u = sdp->uart;
- uint32_t div = LPC11xx_UART_PCLK / (sdp->config->sc_speed << 4);
- u->LCR = sdp->config->sc_lcr | LCR_DLAB;
+ uint32_t div = LPC11xx_UART_PCLK / (config->sc_speed << 4);
+ u->LCR = config->sc_lcr | LCR_DLAB;
u->DLL = div;
u->DLM = div >> 8;
- u->LCR = sdp->config->sc_lcr;
- u->FCR = FCR_ENABLE | FCR_RXRESET | FCR_TXRESET | sdp->config->sc_fcr;
+ u->LCR = config->sc_lcr;
+ u->FCR = FCR_ENABLE | FCR_RXRESET | FCR_TXRESET | config->sc_fcr;
u->ACR = 0;
u->FDR = 0x10;
u->TER = TER_ENABLE;
@@ -242,11 +243,14 @@ void sd_lld_init(void) { * @brief Low level serial driver configuration and (re)start.
*
* @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] config the architecture-dependent serial driver configuration.
+ * If this parameter is set to @p NULL then a default
+ * configuration is used.
*/
-void sd_lld_start(SerialDriver *sdp) {
+void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
- if (sdp->config == NULL)
- sdp->config = &default_config;
+ if (config == NULL)
+ config = &default_config;
if (sdp->state == SD_STOP) {
#if USE_LPC11xx_UART0
@@ -257,7 +261,7 @@ void sd_lld_start(SerialDriver *sdp) { }
#endif
}
- uart_init(sdp);
+ uart_init(sdp, config);
}
/**
diff --git a/os/hal/platforms/LPC11xx/serial_lld.h b/os/hal/platforms/LPC11xx/serial_lld.h index e14cea679..bb91680cf 100644 --- a/os/hal/platforms/LPC11xx/serial_lld.h +++ b/os/hal/platforms/LPC11xx/serial_lld.h @@ -84,29 +84,29 @@ /*===========================================================================*/
/**
- * @brief UART0 driver enable switch.
+ * @brief UART0 driver enable switch.
* @details If set to @p TRUE the support for UART0 is included.
- * @note The default is @p TRUE .
+ * @note The default is @p TRUE .
*/
#if !defined(USE_LPC11xx_UART0) || defined(__DOXYGEN__)
#define USE_LPC11xx_UART0 TRUE
#endif
/**
- * @brief FIFO preload parameter.
+ * @brief FIFO preload parameter.
* @details Configuration parameter, this values defines how many bytes are
- * preloaded in the HW transmit FIFO for each interrupt, the maximum value is
- * 16 the minimum is 1.
- * @note An high value reduces the number of interrupts generated but can
- * also increase the worst case interrupt response time because the
- * preload loops.
+ * preloaded in the HW transmit FIFO for each interrupt, the maximum
+ * value is 16 the minimum is 1.
+ * @note An high value reduces the number of interrupts generated but can
+ * also increase the worst case interrupt response time because the
+ * preload loops.
*/
#if !defined(LPC11xx_UART_FIFO_PRELOAD) || defined(__DOXYGEN__)
#define LPC11xx_UART_FIFO_PRELOAD 16
#endif
/**
- * @brief UART0 interrupt priority level setting.
+ * @brief UART0 interrupt priority level setting.
*/
#if !defined(LPC11xx_UART0_PRIORITY) || defined(__DOXYGEN__)
#define LPC11xx_UART0_PRIORITY 3
@@ -117,7 +117,7 @@ /*===========================================================================*/
#if (LPC11xx_UART_FIFO_PRELOAD < 1) || (LPC11xx_UART_FIFO_PRELOAD > 16)
-#error "invalid LPC214x_UART_FIFO_PRELOAD setting"
+#error "invalid LPC11xx_UART_FIFO_PRELOAD setting"
#endif
/*===========================================================================*/
@@ -130,7 +130,7 @@ typedef uint32_t sdflags_t;
/**
- * @brief LPC214x Serial Driver configuration structure.
+ * @brief LPC11xx Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
*/
@@ -156,8 +156,6 @@ typedef struct { _base_asynchronous_channel_data \
/* Driver state.*/ \
sdstate_t state; \
- /* Current configuration data.*/ \
- const SerialConfig *config; \
/* Input queue.*/ \
InputQueue iqueue; \
/* Output queue.*/ \
@@ -190,7 +188,7 @@ extern SerialDriver SD1; extern "C" {
#endif
void sd_lld_init(void);
- void sd_lld_start(SerialDriver *sdp);
+ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
void sd_lld_stop(SerialDriver *sdp);
#ifdef __cplusplus
}
diff --git a/os/hal/platforms/LPC13xx/serial_lld.c b/os/hal/platforms/LPC13xx/serial_lld.c index 8c3e73ca1..53fd7e11e 100644 --- a/os/hal/platforms/LPC13xx/serial_lld.c +++ b/os/hal/platforms/LPC13xx/serial_lld.c @@ -58,16 +58,17 @@ static const SerialConfig default_config = { * @brief UART initialization.
*
* @param[in] sdp communication channel associated to the UART
+ * @param[in] config the architecture-dependent serial driver configuration
*/
-static void uart_init(SerialDriver *sdp) {
+static void uart_init(SerialDriver *sdp, const SerialConfig *config) {
LPC_UART_TypeDef *u = sdp->uart;
- uint32_t div = LPC13xx_UART_PCLK / (sdp->config->sc_speed << 4);
- u->LCR = sdp->config->sc_lcr | LCR_DLAB;
+ uint32_t div = LPC13xx_UART_PCLK / (config->sc_speed << 4);
+ u->LCR = config->sc_lcr | LCR_DLAB;
u->DLL = div;
u->DLM = div >> 8;
- u->LCR = sdp->config->sc_lcr;
- u->FCR = FCR_ENABLE | FCR_RXRESET | FCR_TXRESET | sdp->config->sc_fcr;
+ u->LCR = config->sc_lcr;
+ u->FCR = FCR_ENABLE | FCR_RXRESET | FCR_TXRESET | config->sc_fcr;
u->ACR = 0;
u->FDR = 0x10;
u->TER = TER_ENABLE;
@@ -242,11 +243,14 @@ void sd_lld_init(void) { * @brief Low level serial driver configuration and (re)start.
*
* @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] config the architecture-dependent serial driver configuration.
+ * If this parameter is set to @p NULL then a default
+ * configuration is used.
*/
-void sd_lld_start(SerialDriver *sdp) {
+void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
- if (sdp->config == NULL)
- sdp->config = &default_config;
+ if (config == NULL)
+ config = &default_config;
if (sdp->state == SD_STOP) {
#if USE_LPC13xx_UART0
@@ -257,7 +261,7 @@ void sd_lld_start(SerialDriver *sdp) { }
#endif
}
- uart_init(sdp);
+ uart_init(sdp, config);
}
/**
diff --git a/os/hal/platforms/LPC13xx/serial_lld.h b/os/hal/platforms/LPC13xx/serial_lld.h index c6503fc08..0426c6d5f 100644 --- a/os/hal/platforms/LPC13xx/serial_lld.h +++ b/os/hal/platforms/LPC13xx/serial_lld.h @@ -84,29 +84,29 @@ /*===========================================================================*/
/**
- * @brief UART0 driver enable switch.
+ * @brief UART0 driver enable switch.
* @details If set to @p TRUE the support for UART0 is included.
- * @note The default is @p TRUE .
+ * @note The default is @p TRUE .
*/
#if !defined(USE_LPC13xx_UART0) || defined(__DOXYGEN__)
#define USE_LPC13xx_UART0 TRUE
#endif
/**
- * @brief FIFO preload parameter.
+ * @brief FIFO preload parameter.
* @details Configuration parameter, this values defines how many bytes are
- * preloaded in the HW transmit FIFO for each interrupt, the maximum value is
- * 16 the minimum is 1.
- * @note An high value reduces the number of interrupts generated but can
- * also increase the worst case interrupt response time because the
- * preload loops.
+ * preloaded in the HW transmit FIFO for each interrupt, the maximum
+ * value is 16 the minimum is 1.
+ * @note An high value reduces the number of interrupts generated but can
+ * also increase the worst case interrupt response time because the
+ * preload loops.
*/
#if !defined(LPC13xx_UART_FIFO_PRELOAD) || defined(__DOXYGEN__)
#define LPC13xx_UART_FIFO_PRELOAD 16
#endif
/**
- * @brief UART0 interrupt priority level setting.
+ * @brief UART0 interrupt priority level setting.
*/
#if !defined(LPC13xx_UART0_PRIORITY) || defined(__DOXYGEN__)
#define LPC13xx_UART0_PRIORITY 3
@@ -117,7 +117,7 @@ /*===========================================================================*/
#if (LPC13xx_UART_FIFO_PRELOAD < 1) || (LPC13xx_UART_FIFO_PRELOAD > 16)
-#error "invalid LPC214x_UART_FIFO_PRELOAD setting"
+#error "invalid LPC13xx_UART_FIFO_PRELOAD setting"
#endif
/*===========================================================================*/
@@ -125,12 +125,12 @@ /*===========================================================================*/
/**
- * @brief Serial Driver condition flags type.
+ * @brief Serial Driver condition flags type.
*/
typedef uint32_t sdflags_t;
/**
- * @brief LPC214x Serial Driver configuration structure.
+ * @brief LPC13xx Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
*/
@@ -156,8 +156,6 @@ typedef struct { _base_asynchronous_channel_data \
/* Driver state.*/ \
sdstate_t state; \
- /* Current configuration data.*/ \
- const SerialConfig *config; \
/* Input queue.*/ \
InputQueue iqueue; \
/* Output queue.*/ \
@@ -190,7 +188,7 @@ extern SerialDriver SD1; extern "C" {
#endif
void sd_lld_init(void);
- void sd_lld_start(SerialDriver *sdp);
+ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
void sd_lld_stop(SerialDriver *sdp);
#ifdef __cplusplus
}
diff --git a/os/hal/platforms/MSP430/serial_lld.c b/os/hal/platforms/MSP430/serial_lld.c index 1dc6399f1..8186813fb 100644 --- a/os/hal/platforms/MSP430/serial_lld.c +++ b/os/hal/platforms/MSP430/serial_lld.c @@ -18,8 +18,9 @@ */
/**
- * @file MSP430/serial_lld.c
- * @brief MSP430 low level serial driver code.
+ * @file MSP430/serial_lld.c
+ * @brief MSP430 low level serial driver code.
+ *
* @addtogroup MSP430_SERIAL
* @{
*/
@@ -88,9 +89,9 @@ static void notify1(void) { }
/**
- * @brief USART0 initialization.
+ * @brief USART0 initialization.
*
- * @param[in] config the architecture-dependent serial driver configuration
+ * @param[in] config the architecture-dependent serial driver configuration
*/
static void usart0_init(const SerialConfig *config) {
@@ -110,7 +111,7 @@ static void usart0_init(const SerialConfig *config) { }
/**
- * @brief USART0 de-initialization.
+ * @brief USART0 de-initialization.
*/
static void usart0_deinit(void) {
@@ -132,9 +133,9 @@ static void notify2(void) { }
/**
- * @brief USART1 initialization.
+ * @brief USART1 initialization.
*
- * @param[in] config the architecture-dependent serial driver configuration
+ * @param[in] config the architecture-dependent serial driver configuration
*/
static void usart1_init(const SerialConfig *config) {
@@ -154,7 +155,7 @@ static void usart1_init(const SerialConfig *config) { }
/**
- * @brief USART1 de-initialization.
+ * @brief USART1 de-initialization.
*/
static void usart1_deinit(void) {
@@ -236,7 +237,7 @@ CH_IRQ_HANDLER(USART1RX_VECTOR) { /*===========================================================================*/
/**
- * Low level serial driver initialization.
+ * @brief Low level serial driver initialization.
*/
void sd_lld_init(void) {
@@ -254,11 +255,14 @@ void sd_lld_init(void) { }
/**
- * @brief Low level serial driver configuration and (re)start.
+ * @brief Low level serial driver configuration and (re)start.
*
- * @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] config the architecture-dependent serial driver configuration.
+ * If this parameter is set to @p NULL then a default
+ * configuration is used.
*/
-void sd_lld_start(SerialDriver *sdp) {
+void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
if (sdp->config == NULL)
sdp->config = &default_config;
@@ -278,11 +282,11 @@ void sd_lld_start(SerialDriver *sdp) { }
/**
- * @brief Low level serial driver stop.
+ * @brief Low level serial driver stop.
* @details De-initializes the USART, stops the associated clock, resets the
* interrupt vector.
*
- * @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] sdp pointer to a @p SerialDriver object
*/
void sd_lld_stop(SerialDriver *sdp) {
diff --git a/os/hal/platforms/MSP430/serial_lld.h b/os/hal/platforms/MSP430/serial_lld.h index ad7ae7dd4..d19c9160d 100644 --- a/os/hal/platforms/MSP430/serial_lld.h +++ b/os/hal/platforms/MSP430/serial_lld.h @@ -18,8 +18,9 @@ */
/**
- * @file MSP430/serial_lld.h
- * @brief MSP430 low level serial driver header.
+ * @file MSP430/serial_lld.h
+ * @brief MSP430 low level serial driver header.
+ *
* @addtogroup MSP430_SERIAL
* @{
*/
@@ -38,18 +39,18 @@ /*===========================================================================*/
/**
- * @brief USART0 driver enable switch.
+ * @brief USART0 driver enable switch.
* @details If set to @p TRUE the support for USART0 is included.
- * @note The default is @p TRUE.
+ * @note The default is @p TRUE.
*/
#if !defined(USE_MSP430_USART0) || defined(__DOXYGEN__)
#define USE_MSP430_USART0 TRUE
#endif
/**
- * @brief USART1 driver enable switch.
+ * @brief USART1 driver enable switch.
* @details If set to @p TRUE the support for USART1 is included.
- * @note The default is @p FALSE.
+ * @note The default is @p FALSE.
*/
#if !defined(USE_MSP430_USART1) || defined(__DOXYGEN__)
#define USE_MSP430_USART1 TRUE
@@ -64,12 +65,12 @@ /*===========================================================================*/
/**
- * Serial Driver condition flags type.
+ * @brief Serial Driver condition flags type.
*/
typedef uint8_t sdflags_t;
/**
- * @brief MSP430 Serial Driver configuration structure.
+ * @brief MSP430 Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
*/
@@ -95,8 +96,6 @@ typedef struct { _base_asynchronous_channel_data \
/* Driver state.*/ \
sdstate_t state; \
- /* Current configuration data.*/ \
- const SerialConfig *config; \
/* Input queue.*/ \
InputQueue iqueue; \
/* Output queue.*/ \
@@ -116,8 +115,8 @@ typedef struct { /*===========================================================================*/
/**
- * @brief Macro for baud rate computation.
- * @note Make sure the final baud rate is within tolerance.
+ * @brief Macro for baud rate computation.
+ * @note Make sure the final baud rate is within tolerance.
*/
#define UBR(b) (SMCLK / (b))
@@ -136,7 +135,7 @@ extern SerialDriver SD2; extern "C" {
#endif
void sd_lld_init(void);
- void sd_lld_start(SerialDriver *sdp);
+ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
void sd_lld_stop(SerialDriver *sdp);
#ifdef __cplusplus
}
diff --git a/os/hal/platforms/Posix/serial_lld.c b/os/hal/platforms/Posix/serial_lld.c index b312fccbd..290e39c8f 100644 --- a/os/hal/platforms/Posix/serial_lld.c +++ b/os/hal/platforms/Posix/serial_lld.c @@ -202,7 +202,7 @@ static bool_t outint(SerialDriver *sdp) { /*===========================================================================*/
/**
- * Low level serial driver initialization.
+ * @brief Low level serial driver initialization.
*/
void sd_lld_init(void) {
@@ -222,9 +222,9 @@ void sd_lld_init(void) { }
/**
- * @brief Low level serial driver configuration and (re)start.
+ * @brief Low level serial driver configuration and (re)start.
*
- * @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] sdp pointer to a @p SerialDriver object
*/
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
@@ -243,11 +243,11 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) { }
/**
- * @brief Low level serial driver stop.
+ * @brief Low level serial driver stop.
* @details De-initializes the USART, stops the associated clock, resets the
* interrupt vector.
*
- * @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] sdp pointer to a @p SerialDriver object
*/
void sd_lld_stop(SerialDriver *sdp) {
diff --git a/os/hal/platforms/Posix/serial_lld.h b/os/hal/platforms/Posix/serial_lld.h index 53ba4af95..4ffa0c544 100644 --- a/os/hal/platforms/Posix/serial_lld.h +++ b/os/hal/platforms/Posix/serial_lld.h @@ -39,41 +39,41 @@ /*===========================================================================*/
/**
- * @brief Serial buffers size.
+ * @brief Serial buffers size.
* @details Configuration parameter, you can change the depth of the queue
- * buffers depending on the requirements of your application.
+ * buffers depending on the requirements of your application.
*/
#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
#define SERIAL_BUFFERS_SIZE 1024
#endif
/**
- * @brief SD1 driver enable switch.
+ * @brief SD1 driver enable switch.
* @details If set to @p TRUE the support for SD1 is included.
- * @note The default is @p TRUE.
+ * @note The default is @p TRUE.
*/
#if !defined(USE_SIM_SERIAL1) || defined(__DOXYGEN__)
#define USE_SIM_SERIAL1 TRUE
#endif
/**
- * @brief SD2 driver enable switch.
+ * @brief SD2 driver enable switch.
* @details If set to @p TRUE the support for SD2 is included.
- * @note The default is @p TRUE.
+ * @note The default is @p TRUE.
*/
#if !defined(USE_SIM_SERIAL2) || defined(__DOXYGEN__)
#define USE_SIM_SERIAL2 TRUE
#endif
/**
- * @brief Listen port for SD1.
+ * @brief Listen port for SD1.
*/
#if !defined(SD1_PORT) || defined(__DOXYGEN__)
#define SIM_SD1_PORT 29001
#endif
/**
- * @brief Listen port for SD2.
+ * @brief Listen port for SD2.
*/
#if !defined(SD2_PORT) || defined(__DOXYGEN__)
#define SIM_SD2_PORT 29002
@@ -88,24 +88,23 @@ /*===========================================================================*/
/**
- * Serial Driver condition flags type.
+ * @brief Serial Driver condition flags type.
*/
typedef uint32_t sdflags_t;
/**
- * @brief Generic Serial Driver configuration structure.
+ * @brief Generic Serial Driver configuration structure.
* @details An instance of this structure must be passed to @p sdStart()
* in order to configure and start a serial driver operations.
- *
- * @note This structure content is architecture dependent, each driver
- * implementation defines its own version and the custom static
- * initializers.
+ * @note This structure content is architecture dependent, each driver
+ * implementation defines its own version and the custom static
+ * initializers.
*/
typedef struct {
} SerialConfig;
/**
- * @brief @p SerialDriver specific data.
+ * @brief @p SerialDriver specific data.
*/
#define _serial_driver_data \
_base_asynchronous_channel_data \
diff --git a/os/hal/platforms/SPC56x/serial_lld.h b/os/hal/platforms/SPC56x/serial_lld.h index 7d6ef0352..5dc9c8c64 100644 --- a/os/hal/platforms/SPC56x/serial_lld.h +++ b/os/hal/platforms/SPC56x/serial_lld.h @@ -111,7 +111,7 @@ typedef struct { } SerialConfig;
/**
- * @brief @p SerialDriver specific data.
+ * @brief @p SerialDriver specific data.
*/
#define _serial_driver_data \
_base_asynchronous_channel_data \
diff --git a/os/hal/platforms/STM8/hal_lld.c b/os/hal/platforms/STM8/hal_lld.c index 0d5791236..7a2d1bc1f 100644 --- a/os/hal/platforms/STM8/hal_lld.c +++ b/os/hal/platforms/STM8/hal_lld.c @@ -37,10 +37,10 @@ /*===========================================================================*/
/**
- * @brief PAL setup.
+ * @brief PAL setup.
* @details Digital I/O ports static configuration as defined in @p board.h.
*/
-const STM8GPIOConfig pal_default_config =
+ROMCONST STM8GPIOConfig pal_default_config =
{
{
{VAL_GPIOAODR, 0, VAL_GPIOADDR, VAL_GPIOACR1, VAL_GPIOACR2},
@@ -78,7 +78,7 @@ void hal_lld_init(void) { while ((CLK_ICKR & 2) == 0) /* HSIRDY */
;
#elif STM8_CLOCK_SOURCE == CLK_SOURCE_LSI
- CLK_ICKR = 8; /* LSIEN */
+ CLK_ICKR = 8; /* LSIEN */
while ((CLK_ICKR & 16) == 0) /* LSIRDY */
;
#else /* STM8_CLOCK_SOURCE == CLK_SOURCE_HSE */
@@ -100,7 +100,7 @@ void hal_lld_init(void) { /* Clocks initially all disabled.*/
CLK_PCKENR1 = 0;
CLK_PCKENR2 = 0;
-
+
/* Other clock related initializations.*/
CLK_CSSR = 0;
CLK_CCOR = 0;
diff --git a/os/hal/platforms/STM8/hal_lld.h b/os/hal/platforms/STM8/hal_lld.h index aba5013b3..786843ffc 100644 --- a/os/hal/platforms/STM8/hal_lld.h +++ b/os/hal/platforms/STM8/hal_lld.h @@ -66,21 +66,21 @@ /*===========================================================================*/
/**
- * @brief Clock source setting.
+ * @brief Clock source setting.
*/
#if !defined(STM8_CLOCK_SOURCE) || defined(__DOXYGEN__)
#define STM8_CLOCK_SOURCE CLK_SOURCE_DEFAULT
#endif
/**
- * @brief HSI clock divider.
+ * @brief HSI clock divider.
*/
#if !defined(STM8_HSI_DIVIDER) || defined(__DOXYGEN__)
#define STM8_HSI_DIVIDER CLK_HSI_DIV8
#endif
/**
- * @brief CPU clock divider.
+ * @brief CPU clock divider.
*/
#if !defined(STM8_CPU_DIVIDER) || defined(__DOXYGEN__)
#define STM8_CPU_DIVIDER CLK_CPU_DIV1
diff --git a/os/hal/platforms/STM8/pal_lld.h b/os/hal/platforms/STM8/pal_lld.h index 88f68dd37..65ddeedea 100644 --- a/os/hal/platforms/STM8/pal_lld.h +++ b/os/hal/platforms/STM8/pal_lld.h @@ -38,6 +38,9 @@ /* I/O Ports Types and constants. */
/*===========================================================================*/
+/**
+ * @brief GPIO port representation. + */
typedef struct {
volatile uint8_t ODR;
volatile uint8_t IDR;
@@ -191,7 +194,7 @@ typedef gpio_t *ioportid_t; */
#define pal_lld_setgroupmode(port, mask, mode) ((void)(mode))
-extern const STM8GPIOConfig pal_default_config;
+extern ROMCONST STM8GPIOConfig pal_default_config;
#endif /* CH_HAL_USE_PAL */
diff --git a/os/hal/platforms/STM8/serial_lld.c b/os/hal/platforms/STM8/serial_lld.c index a0b85619c..d3b49b1e4 100644 --- a/os/hal/platforms/STM8/serial_lld.c +++ b/os/hal/platforms/STM8/serial_lld.c @@ -79,7 +79,7 @@ SerialDriver SD3; /**
* @brief Driver default configuration.
*/
-static const SerialConfig default_config = {
+static ROMCONST SerialConfig default_config = {
BBR(SERIAL_DEFAULT_BITRATE),
SD_MODE_PARITY_NONE | SD_MODE_STOP_1
};
diff --git a/os/hal/templates/serial_lld.c b/os/hal/templates/serial_lld.c index 0293f28e7..01d50de68 100644 --- a/os/hal/templates/serial_lld.c +++ b/os/hal/templates/serial_lld.c @@ -67,6 +67,9 @@ void sd_lld_init(void) { * @brief Low level serial driver configuration and (re)start.
*
* @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] config the architecture-dependent serial driver configuration.
+ * If this parameter is set to @p NULL then a default
+ * configuration is used.
*/
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
diff --git a/os/kernel/templates/chtypes.h b/os/kernel/templates/chtypes.h index e54c55100..164ccbe60 100644 --- a/os/kernel/templates/chtypes.h +++ b/os/kernel/templates/chtypes.h @@ -97,6 +97,19 @@ typedef int32_t cnt_t; #define INLINE inline
/**
+ * @brief ROM constant modifier.
+ * @note This is required because some compilers require a custom keyword,
+ * usually this macro is just set to "const" for the GCC compiler.
+ * @note This macro is not used to place constants in different address
+ * spaces (like AVR requires as example) because it is assumed that
+ * a pointer to a ROMCONST constant is compatible with a pointer
+ * to a normal variable. It is just like the "const" keyword but
+ * requires that the constant is placed in ROM if the architecture
+ * supports it. + */
+#define ROMCONST const
+
+/**
* @brief Packed structure modifier (within).
*/
#define PACK_STRUCT_STRUCT __attribute__((packed))
diff --git a/os/ports/GCC/ARM7/chtypes.h b/os/ports/GCC/ARM7/chtypes.h index 225263345..6fcfe1af0 100644 --- a/os/ports/GCC/ARM7/chtypes.h +++ b/os/ports/GCC/ARM7/chtypes.h @@ -18,8 +18,9 @@ */
/**
- * @file ARM7/chtypes.h
- * @brief ARM7 architecture port system types.
+ * @file ARM7/chtypes.h
+ * @brief ARM7 architecture port system types.
+ *
* @addtogroup ARM7_CORE
* @{
*/
@@ -47,9 +48,33 @@ typedef uint32_t eventmask_t; /**< Events mask. */ typedef uint32_t systime_t; /**< System time. */
typedef int32_t cnt_t; /**< Resources counter. */
+/**
+ * @brief Inline function modifier.
+ */
#define INLINE inline
+
+/**
+ * @brief ROM constant modifier.
+ * @note It is set to use the "const" keyword in this port.
+ */
+#define ROMCONST const
+
+/**
+ * @brief Packed structure modifier (within).
+ * @note It uses the "packed" GCC attribute.
+ */
#define PACK_STRUCT_STRUCT __attribute__((packed))
+
+/**
+ * @brief Packed structure modifier (before).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_BEGIN
+
+/**
+ * @brief Packed structure modifier (after).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_END
#endif /* _CHTYPES_H_ */
diff --git a/os/ports/GCC/ARMCMx/chtypes.h b/os/ports/GCC/ARMCMx/chtypes.h index ef35d6324..e5e68b92f 100644 --- a/os/ports/GCC/ARMCMx/chtypes.h +++ b/os/ports/GCC/ARMCMx/chtypes.h @@ -46,9 +46,33 @@ typedef uint32_t eventmask_t; /**< Events mask. */ typedef uint32_t systime_t; /**< System time. */
typedef int32_t cnt_t; /**< Resources counter. */
+/**
+ * @brief Inline function modifier.
+ */
#define INLINE inline
+
+/**
+ * @brief ROM constant modifier.
+ * @note It is set to use the "const" keyword in this port.
+ */
+#define ROMCONST const
+
+/**
+ * @brief Packed structure modifier (within).
+ * @note It uses the "packed" GCC attribute.
+ */
#define PACK_STRUCT_STRUCT __attribute__((packed))
+
+/**
+ * @brief Packed structure modifier (before).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_BEGIN
+
+/**
+ * @brief Packed structure modifier (after).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_END
#endif /* _CHTYPES_H_ */
diff --git a/os/ports/GCC/AVR/chtypes.h b/os/ports/GCC/AVR/chtypes.h index 6c8c474c6..f180dfd4b 100644 --- a/os/ports/GCC/AVR/chtypes.h +++ b/os/ports/GCC/AVR/chtypes.h @@ -18,8 +18,9 @@ */
/**
- * @file AVR/chtypes.h
- * @brief AVR architecture port system types.
+ * @file AVR/chtypes.h
+ * @brief AVR architecture port system types.
+ *
* @addtogroup AVR_CORE
* @{
*/
@@ -47,9 +48,33 @@ typedef uint8_t eventmask_t; /**< Events mask. */ typedef uint16_t systime_t; /**< System time. */
typedef int8_t cnt_t; /**< Resources counter. */
-#define INLINE inline
+/**
+ * @brief Inline function modifier.
+ */
+#define INLINE inline
+
+/**
+ * @brief ROM constant modifier.
+ * @note It is set to use the "const" keyword in this port.
+ */
+#define ROMCONST const
+
+/**
+ * @brief Packed structure modifier (within).
+ * @note It uses the "packed" GCC attribute.
+ */
#define PACK_STRUCT_STRUCT __attribute__((packed))
+
+/**
+ * @brief Packed structure modifier (before).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_BEGIN
+
+/**
+ * @brief Packed structure modifier (after).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_END
#endif /* _CHTYPES_H_ */
diff --git a/os/ports/GCC/MSP430/chtypes.h b/os/ports/GCC/MSP430/chtypes.h index 8f308f2d4..3798a14dc 100644 --- a/os/ports/GCC/MSP430/chtypes.h +++ b/os/ports/GCC/MSP430/chtypes.h @@ -18,8 +18,9 @@ */
/**
- * @file MSP430/chtypes.h
- * @brief MSP430 architecture port system types.
+ * @file MSP430/chtypes.h
+ * @brief MSP430 architecture port system types.
+ *
* @addtogroup MSP430_CORE
* @{
*/
@@ -47,9 +48,33 @@ typedef uint16_t eventmask_t; /**< Events mask. */ typedef uint16_t systime_t; /**< System time. */
typedef int16_t cnt_t; /**< Resources counter. */
-#define INLINE inline
+/**
+ * @brief Inline function modifier.
+ */
+#define INLINE inline
+
+/**
+ * @brief ROM constant modifier.
+ * @note It is set to use the "const" keyword in this port.
+ */
+#define ROMCONST const
+
+/**
+ * @brief Packed structure modifier (within).
+ * @note It uses the "packed" GCC attribute.
+ */
#define PACK_STRUCT_STRUCT __attribute__((packed))
+
+/**
+ * @brief Packed structure modifier (before).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_BEGIN
+
+/**
+ * @brief Packed structure modifier (after).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_END
#endif /* _CHTYPES_H_ */
diff --git a/os/ports/GCC/PPC/chtypes.h b/os/ports/GCC/PPC/chtypes.h index e6eedbde0..f0be524b6 100644 --- a/os/ports/GCC/PPC/chtypes.h +++ b/os/ports/GCC/PPC/chtypes.h @@ -60,16 +60,33 @@ typedef uint32_t eventmask_t; /**< Events mask. */ typedef uint32_t systime_t; /**< System time. */
typedef int32_t cnt_t; /**< Resources counter. */
-/** Inline function modifier. */
-#define INLINE inline
+/**
+ * @brief Inline function modifier.
+ */
+#define INLINE inline
+
+/**
+ * @brief ROM constant modifier.
+ * @note It is set to use the "const" keyword in this port.
+ */
+#define ROMCONST const
-/** Packed structure modifier (within). */
+/**
+ * @brief Packed structure modifier (within).
+ * @note It uses the "packed" GCC attribute.
+ */
#define PACK_STRUCT_STRUCT __attribute__((packed))
-/** Packed structure modifier (before). */
+/**
+ * @brief Packed structure modifier (before).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_BEGIN
-/** Packed structure modifier (after). */
+/**
+ * @brief Packed structure modifier (after).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_END
#endif /* _CHTYPES_H_ */
diff --git a/os/ports/GCC/SIMIA32/chtypes.h b/os/ports/GCC/SIMIA32/chtypes.h index 08d5b4cea..327de745a 100644 --- a/os/ports/GCC/SIMIA32/chtypes.h +++ b/os/ports/GCC/SIMIA32/chtypes.h @@ -40,9 +40,33 @@ typedef uint32_t eventmask_t; /**< Events mask. */ typedef uint32_t systime_t; /**< System time. */
typedef int32_t cnt_t; /**< Resources counter. */
-#define INLINE inline
+/**
+ * @brief Inline function modifier.
+ */
+#define INLINE inline
+
+/**
+ * @brief ROM constant modifier.
+ * @note It is set to use the "const" keyword in this port.
+ */
+#define ROMCONST const
+
+/**
+ * @brief Packed structure modifier (within).
+ * @note It uses the "packed" GCC attribute.
+ */
#define PACK_STRUCT_STRUCT __attribute__((packed))
+
+/**
+ * @brief Packed structure modifier (before).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_BEGIN
+
+/**
+ * @brief Packed structure modifier (after).
+ * @note Empty in this port.
+ */
#define PACK_STRUCT_END
#endif /* _CHTYPES_H_ */
diff --git a/os/ports/RC/STM8/chtypes.h b/os/ports/RC/STM8/chtypes.h index d2245b9c0..fd3370563 100644 --- a/os/ports/RC/STM8/chtypes.h +++ b/os/ports/RC/STM8/chtypes.h @@ -18,14 +18,10 @@ */
/**
- * @file templates/chtypes.h
- * @brief System types template.
- * @details The types defined in this file may change depending on the target
- * architecture. You may also try to optimize the size of the various
- * types in order to privilege size or performance, be careful in
- * doing so.
+ * @file STM8/chtypes.h
+ * @brief STM8 port system types.
*
- * @addtogroup types
+ * @addtogroup STM8_CORE
* @{
*/
@@ -40,15 +36,15 @@ //#include <stdint.h>
//#endif
-typedef unsigned char uint8_t;
-typedef signed char int8_t;
-typedef unsigned int uint16_t;
-typedef signed int int16_t;
-typedef unsigned long uint32_t;
-typedef signed long int32_t;
-typedef uint8_t uint_fast8_t;
-typedef uint16_t uint_fast16_t;
-typedef uint32_t uint_fast32_t;
+typedef unsigned char uint8_t; /**< C99-style 8 bits unsigned. */
+typedef signed char int8_t; /**< C99-style 8 bits signed. */
+typedef unsigned int uint16_t; /**< C99-style 16 bits unsigned. */
+typedef signed int int16_t; /**< C99-style 16 bits signed. */
+typedef unsigned long uint32_t; /**< C99-style 32 bits unsigned. */
+typedef signed long int32_t; /**< C99-style 32 bits signed. */
+typedef uint8_t uint_fast8_t; /**< C99-style 8 bits unsigned. */
+typedef uint16_t uint_fast16_t; /**< C99-style 16 bits unsigned. */
+typedef uint32_t uint_fast32_t; /**< C99-style 32 bits unsigned. */
/**
* @brief Boolean, recommended the fastest signed.
@@ -106,17 +102,26 @@ typedef int16_t cnt_t; #define INLINE inline
/**
+ * @brief ROM constant modifier.
+ * @note Uses the custom "code" keyword in this port.
+ */
+#define ROMCONST code
+
+/**
* @brief Packed structure modifier (within).
+ * @note Empty in this port.
*/
#define PACK_STRUCT_STRUCT
/**
* @brief Packed structure modifier (before).
+ * @note Empty in this port.
*/
#define PACK_STRUCT_BEGIN
/**
* @brief Packed structure modifier (after).
+ * @note Empty in this port.
*/
#define PACK_STRUCT_END
diff --git a/readme.txt b/readme.txt index 8d8177b3e..568d3668b 100644 --- a/readme.txt +++ b/readme.txt @@ -59,7 +59,15 @@ *** 1.5.6 ***
- FIX: Fixed wrong macros in chioch.h (bug 2989468).
- FIX: Fixed wrong macro check in serial.h (bug 2989459)(backported in 1.4.3).
-- Various documentation fixes.
+- NEW: Added a ROMCONST macro in chtypes.h, this macro must be used for
+ constant that must be placed in code space, it should not be assumed that
+ the "const" keyword does that. Note that this macro is not used to place
+ constants in different address spaces (AVR) because it is assumed that a
+ pointer to a ROMCONST variable is compatible with a normal pointer.
+- OPT: Internal optimization in the serial driver, it now is a bit smaller
+ and uses less RAM (all architectures).
+- Various documentation fixes, added an article covering debugging under
+ ChibiOS/RT.
*** 1.5.5 ***
- FIX: Removed some "dead" code in the old ARMv7-M files (there are new
|