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

This commit is contained in:
gdisirio 2010-04-21 14:11:12 +00:00
parent 3621ac37b0
commit 75792b3d6a
28 changed files with 527 additions and 205 deletions

View File

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

138
docs/src/debug.dox Normal file
View File

@ -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 :-)
* .
*/

View File

@ -20,6 +20,7 @@
/**
* @file AVR/serial_lld.c
* @brief AVR low level serial driver code.
*
* @addtogroup AVR_SERIAL
* @{
*/
@ -89,6 +90,7 @@ static void notify1(void) {
/**
* @brief USART0 initialization.
*
* @param[in] config the architecture-dependent serial driver configuration
*/
static void usart0_init(const SerialConfig *config) {
@ -119,6 +121,7 @@ static void notify2(void) {
/**
* @brief USART1 initialization.
*
* @param[in] config the architecture-dependent serial driver configuration
*/
static void usart1_init(const SerialConfig *config) {
@ -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) {
@ -232,21 +235,24 @@ 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 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

View File

@ -20,6 +20,7 @@
/**
* @file AVR/serial_lld.h
* @brief AVR low level serial driver header.
*
* @addtogroup AVR_SERIAL
* @{
*/
@ -91,8 +92,6 @@ typedef struct {
_base_asynchronous_channel_data \
/* Driver state.*/ \
sdstate_t state; \
/* Current configuration data.*/ \
const SerialConfig *config; \
/* Input queue.*/ \
InputQueue iqueue; \
/* Output queue.*/ \
@ -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
}

View File

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

View File

@ -95,8 +95,8 @@
/**
* @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.
* 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.
@ -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
}

View File

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

View File

@ -95,8 +95,8 @@
/**
* @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.
* 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.
@ -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
/*===========================================================================*/
@ -130,7 +130,7 @@
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
}

View File

@ -20,6 +20,7 @@
/**
* @file MSP430/serial_lld.c
* @brief MSP430 low level serial driver code.
*
* @addtogroup MSP430_SERIAL
* @{
*/
@ -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) {
@ -257,8 +258,11 @@ 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;

View File

@ -20,6 +20,7 @@
/**
* @file MSP430/serial_lld.h
* @brief MSP430 low level serial driver header.
*
* @addtogroup MSP430_SERIAL
* @{
*/
@ -64,7 +65,7 @@
/*===========================================================================*/
/**
* Serial Driver condition flags type.
* @brief Serial Driver condition flags type.
*/
typedef uint8_t sdflags_t;
@ -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.*/ \
@ -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
}

View File

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

View File

@ -88,7 +88,7 @@
/*===========================================================================*/
/**
* Serial Driver condition flags type.
* @brief Serial Driver condition flags type.
*/
typedef uint32_t sdflags_t;
@ -96,7 +96,6 @@ typedef uint32_t sdflags_t;
* @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.

View File

@ -40,7 +40,7 @@
* @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},

View File

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

View File

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

View File

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

View File

@ -96,6 +96,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).
*/

View File

@ -20,6 +20,7 @@
/**
* @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_ */

View File

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

View File

@ -20,6 +20,7 @@
/**
* @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. */
/**
* @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_ */

View File

@ -20,6 +20,7 @@
/**
* @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. */
/**
* @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_ */

View File

@ -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. */
/**
* @brief Inline function modifier.
*/
#define INLINE inline
/** Packed structure modifier (within). */
/**
* @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))
/** 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_ */

View File

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

View File

@ -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.
@ -105,18 +101,27 @@ 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

View File

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