diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-03-08 21:19:58 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-03-08 21:19:58 +0000 |
commit | ce7f7103df5f634f7b57d90e115c5824adcb68a0 (patch) | |
tree | 48064ba690d7002bb8fc7b78f3f9dd76729b785c /os/hal/templates | |
parent | 63bf265ddf9ad40ad981c5a145c601972b91426e (diff) | |
download | ChibiOS-ce7f7103df5f634f7b57d90e115c5824adcb68a0.tar.gz ChibiOS-ce7f7103df5f634f7b57d90e115c5824adcb68a0.tar.bz2 ChibiOS-ce7f7103df5f634f7b57d90e115c5824adcb68a0.zip |
MISRA fixes for high level HAL.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7738 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/templates')
-rw-r--r-- | os/hal/templates/can_lld.h | 10 | ||||
-rw-r--r-- | os/hal/templates/halconf.h | 7 | ||||
-rw-r--r-- | os/hal/templates/osal/osal.c | 4 | ||||
-rw-r--r-- | os/hal/templates/osal/osal.h | 51 | ||||
-rw-r--r-- | os/hal/templates/pal_lld.h | 82 | ||||
-rw-r--r-- | os/hal/templates/rtc_lld.h | 23 | ||||
-rw-r--r-- | os/hal/templates/usb_lld.h | 5 |
7 files changed, 153 insertions, 29 deletions
diff --git a/os/hal/templates/can_lld.h b/os/hal/templates/can_lld.h index 72ba6d532..648d62d7d 100644 --- a/os/hal/templates/can_lld.h +++ b/os/hal/templates/can_lld.h @@ -31,6 +31,16 @@ /* Driver constants. */
/*===========================================================================*/
+/**
+ * @brief Number of transmit mailboxes.
+ */
+#define CAN_TX_MAILBOXES 1
+
+/**
+ * @brief Number of receive mailboxes.
+ */
+#define CAN_RX_MAILBOXES 1
+
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
diff --git a/os/hal/templates/halconf.h b/os/hal/templates/halconf.h index d74d13736..568ae7db0 100644 --- a/os/hal/templates/halconf.h +++ b/os/hal/templates/halconf.h @@ -55,6 +55,13 @@ #endif
/**
+ * @brief Enables the DAC subsystem.
+ */
+#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
+#define HAL_USE_DAC FALSE
+#endif
+
+/**
* @brief Enables the EXT subsystem.
*/
#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
diff --git a/os/hal/templates/osal/osal.c b/os/hal/templates/osal/osal.c index 91bc578ed..f13ec1044 100644 --- a/os/hal/templates/osal/osal.c +++ b/os/hal/templates/osal/osal.c @@ -78,8 +78,8 @@ void osalSysHalt(const char *reason) { osalSysDisable();
osal_halt_msg = reason;
- while (1)
- ;
+ while (true) {
+ }
}
/**
diff --git a/os/hal/templates/osal/osal.h b/os/hal/templates/osal/osal.h index 1f567f732..3736256a0 100644 --- a/os/hal/templates/osal/osal.h +++ b/os/hal/templates/osal/osal.h @@ -42,7 +42,7 @@ #endif
#if !defined(TRUE) || defined(__DOXYGEN__)
-#define TRUE (!FALSE)
+#define TRUE 1
#endif
#define OSAL_SUCCESS FALSE
@@ -100,6 +100,20 @@ /* Module pre-compile time settings. */
/*===========================================================================*/
+/**
+ * @brief Enables OSAL assertions.
+ */
+#if !defined(OSAL_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
+#define OSAL_DBG_ENABLE_ASSERTS FALSE
+#endif
+
+/**
+ * @brief Enables OSAL functions parameters checks.
+ */
+#if !defined(OSAL_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
+#define OSAL_DBG_ENABLE_CHECKS FALSE
+#endif
+
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
@@ -148,7 +162,7 @@ typedef struct event_source event_source_t; * @note This type is not part of the OSAL API and is provided
* exclusively as an example and for convenience.
*/
-typedef void (*eventcallback_t)(event_source_t *);
+typedef void (*eventcallback_t)(event_source_t *esp);
/**
* @brief Type of an event flags mask.
@@ -209,7 +223,16 @@ typedef struct { *
* @api
*/
-#define osalDbgAssert(c, remark)
+#define osalDbgAssert(c, remark) do { \
+ /*lint -save -e506 -e774 [2.1, 14.3] Can be a constant by design.*/ \
+ if (OSAL_DBG_ENABLE_ASSERTS != FALSE) { \
+ if (!(c)) { \
+ /*lint -restore*/ \
+ osalSysHalt(__func__); \
+ } \
+ } \
+} while (false)
+
/**
* @brief Function parameters check.
@@ -221,7 +244,16 @@ typedef struct { *
* @api
*/
-#define osalDbgCheck(c)
+#define osalDbgCheck(c) do { \
+ /*lint -save -e506 -e774 [2.1, 14.3] Can be a constant by design.*/ \
+ if (OSAL_DBG_ENABLE_CHECKS != FALSE) { \
+ if (!(c)) { \
+ /*lint -restore*/ \
+ osalSysHalt(__func__); \
+ } \
+ } \
+} while (false)
+
/**
* @brief I-Class state check.
@@ -289,7 +321,7 @@ typedef struct { * @api
*/
#define OSAL_MS2ST(msec) \
- ((systime_t)(((((uint32_t)(msec)) * ((uint32_t)OSAL_ST_FREQUENCY) - 1UL) /\
+ ((systime_t)((((((uint32_t)(msec)) * ((uint32_t)OSAL_ST_FREQUENCY)) - 1UL) /\
1000UL) + 1UL))
/**
@@ -303,7 +335,7 @@ typedef struct { * @api
*/
#define OSAL_US2ST(usec) \
- ((systime_t)(((((uint32_t)(usec)) * ((uint32_t)OSAL_ST_FREQUENCY) - 1UL) /\
+ ((systime_t)((((((uint32_t)(usec)) * ((uint32_t)OSAL_ST_FREQUENCY)) - 1UL) /\
1000000UL) + 1UL))
/** @} */
@@ -354,6 +386,8 @@ typedef struct { /* External declarations. */
/*===========================================================================*/
+extern const char *osal_halt_msg;
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -542,7 +576,7 @@ static inline bool osalOsIsTimeWithinX(systime_t time, systime_t start,
systime_t end) {
- return (bool)(time - start < end - start);
+ return (bool)((time - start) < (end - start));
}
/**
@@ -730,8 +764,9 @@ static inline void osalEventBroadcastFlagsI(event_source_t *esp, osalDbgCheck(esp != NULL);
esp->flags |= flags;
- if (esp->cb != NULL)
+ if (esp->cb != NULL) {
esp->cb(esp);
+ }
}
/**
diff --git a/os/hal/templates/pal_lld.h b/os/hal/templates/pal_lld.h index 3530a96e3..dd04b869f 100644 --- a/os/hal/templates/pal_lld.h +++ b/os/hal/templates/pal_lld.h @@ -51,13 +51,13 @@ typedef struct { /**
* @brief Width, in bits, of an I/O port.
*/
-#define PAL_IOPORTS_WIDTH 32
+#define PAL_IOPORTS_WIDTH 32U
/**
* @brief Whole port mask.
* @brief This macro specifies all the valid bits into a port.
*/
-#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFFFFFF)
+#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFFFFFFU)
/**
* @brief Digital I/O port sized unsigned type.
@@ -110,7 +110,7 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_readport(port) 0
+#define pal_lld_readport(port) 0U
/**
* @brief Reads the output latch.
@@ -122,7 +122,7 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_readlatch(port) 0
+#define pal_lld_readlatch(port) 0U
/**
* @brief Writes a bits mask on a I/O port.
@@ -132,7 +132,12 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_writeport(port, bits)
+#define pal_lld_writeport(port, bits) \
+ do { \
+ (void)port; \
+ (void)bits; \
+ } while (false)
+
/**
* @brief Sets a bits mask on a I/O port.
@@ -145,7 +150,12 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_setport(port, bits)
+#define pal_lld_setport(port, bits) \
+ do { \
+ (void)port; \
+ (void)bits; \
+ } while (false)
+
/**
* @brief Clears a bits mask on a I/O port.
@@ -158,7 +168,12 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_clearport(port, bits)
+#define pal_lld_clearport(port, bits) \
+ do { \
+ (void)port; \
+ (void)bits; \
+ } while (false)
+
/**
* @brief Toggles a bits mask on a I/O port.
@@ -171,7 +186,12 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_toggleport(port, bits)
+#define pal_lld_toggleport(port, bits) \
+ do { \
+ (void)port; \
+ (void)bits; \
+ } while (false)
+
/**
* @brief Reads a group of bits.
@@ -186,8 +206,7 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_readgroup(port, mask, offset) \
- (void)port,(void)mask,(void)offset,0
+#define pal_lld_readgroup(port, mask, offset) 0U
/**
* @brief Writes a group of bits.
@@ -204,7 +223,12 @@ typedef uint32_t ioportid_t; * @notapi
*/
#define pal_lld_writegroup(port, mask, offset, bits) \
- (void)port,(void)mask,(void)offset,(void)bits
+ do { \
+ (void)port; \
+ (void)mask; \
+ (void)offset; \
+ (void)bits; \
+ } while (false)
/**
* @brief Pads group mode setup.
@@ -253,7 +277,12 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_writepad(port, pad, bit)
+#define pal_lld_writepad(port, pad, bit) \
+ do { \
+ (void)port; \
+ (void)pad; \
+ (void)bit; \
+ } while (false)
/**
* @brief Sets a pad logical state to @p PAL_HIGH.
@@ -266,7 +295,12 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_setpad(port, pad)
+#define pal_lld_setpad(port, pad) \
+ do { \
+ (void)port; \
+ (void)pad; \
+ } while (false)
+
/**
* @brief Clears a pad logical state to @p PAL_LOW.
@@ -279,7 +313,12 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_clearpad(port, pad)
+#define pal_lld_clearpad(port, pad) \
+ do { \
+ (void)port; \
+ (void)pad; \
+ } while (false)
+
/**
* @brief Toggles a pad logical state.
@@ -292,7 +331,12 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_togglepad(port, pad)
+#define pal_lld_togglepad(port, pad) \
+ do { \
+ (void)port; \
+ (void)pad; \
+ } while (false)
+
/**
* @brief Pad mode setup.
@@ -308,7 +352,13 @@ typedef uint32_t ioportid_t; *
* @notapi
*/
-#define pal_lld_setpadmode(port, pad, mode)
+#define pal_lld_setpadmode(port, pad, mode) \
+ do { \
+ (void)port; \
+ (void)pad; \
+ (void)mode; \
+ } while (false)
+
#if !defined(__DOXYGEN__)
extern const PALConfig pal_default_config;
diff --git a/os/hal/templates/rtc_lld.h b/os/hal/templates/rtc_lld.h index 30d316572..397aeb5af 100644 --- a/os/hal/templates/rtc_lld.h +++ b/os/hal/templates/rtc_lld.h @@ -41,12 +41,12 @@ /**
* @brief Callback support int the driver.
*/
-#define RTC_SUPPORTS_CALLBACKS PLATFORM_RTC_HAS_INTERRUPTS
+#define RTC_SUPPORTS_CALLBACKS TRUE
/**
* @brief Number of alarms available.
*/
-#define RTC_ALARMS PLATFORM_RTC_NUM_ALARMS
+#define RTC_ALARMS 2
/**
* @brief Presence of a local persistent storage.
@@ -83,6 +83,20 @@ */
typedef uint32_t rtcalarm_t;
+#if (RTC_SUPPORTS_CALLBACKS == TRUE) || defined(__DOXYGEN__)
+/**
+ * @brief Type of an RTC event.
+ */
+typedef enum {
+ RTC_EVENT_SECOND = 0 /** Triggered every second. */
+} rtcevent_t;
+
+/**
+ * @brief Type of a generic RTC callback.
+ */
+typedef void (*rtccb_t)(RTCDriver *rtcp, rtcevent_t event);
+#endif
+
/**
* @brief Type of a structure representing an RTC alarm time stamp.
*/
@@ -91,7 +105,7 @@ typedef struct { uint32_t dummy;
} RTCAlarm;
-#if RTC_HAS_STORAGE || defined(__DOXYGEN__)
+#if (RTC_HAS_STORAGE == TRUE) || defined(__DOXYGEN__)
/**
* @extends FileStream
*
@@ -145,6 +159,9 @@ extern "C" { rtcalarm_t alarm,
RTCAlarm *alarmspec);
#endif
+#if RTC_SUPPORTS_CALLBACKS == TRUE
+ void rtc_lld_set_callback(RTCDriver *rtcp, rtccb_t callback);
+#endif
#ifdef __cplusplus
}
#endif
diff --git a/os/hal/templates/usb_lld.h b/os/hal/templates/usb_lld.h index 649ef7e92..c02a37fca 100644 --- a/os/hal/templates/usb_lld.h +++ b/os/hal/templates/usb_lld.h @@ -46,6 +46,11 @@ */
#define USB_SET_ADDRESS_MODE USB_LATE_SET_ADDRESS
+/**
+ * @brief Method for set address acknowledge.
+ */
+#define USB_SET_ADDRESS_ACK_HANDLING USB_SET_ADDRESS_ACK_SW
+
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
|