aboutsummaryrefslogtreecommitdiffstats
path: root/os/nil
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-03-12 09:28:03 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-03-12 09:28:03 +0000
commitdb0b7ae0626ebdfc3cda7bef8bd7bad343cead23 (patch)
tree8d91763f28c60d249845695c00bbb6aa985d60ed /os/nil
parentfc2af0f5896de947b3c59a9251ac4eef91ed005c (diff)
downloadChibiOS-db0b7ae0626ebdfc3cda7bef8bd7bad343cead23.tar.gz
ChibiOS-db0b7ae0626ebdfc3cda7bef8bd7bad343cead23.tar.bz2
ChibiOS-db0b7ae0626ebdfc3cda7bef8bd7bad343cead23.zip
More MISRA.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7760 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/nil')
-rw-r--r--os/nil/include/nil.h2
-rw-r--r--os/nil/src/nil.c9
-rw-r--r--os/nil/templates/nilconf.h2
-rw-r--r--os/nil/templates/nilcore.h37
-rw-r--r--os/nil/templates/nilcore_timer.h120
-rw-r--r--os/nil/templates/niltypes.h2
6 files changed, 153 insertions, 19 deletions
diff --git a/os/nil/include/nil.h b/os/nil/include/nil.h
index d0dfe18fa..38ccf2a24 100644
--- a/os/nil/include/nil.h
+++ b/os/nil/include/nil.h
@@ -702,7 +702,7 @@ struct nil_system {
*
* @sclass
*/
-#define chThdSleepS(timeout) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, timeout)
+#define chThdSleepS(timeout) (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, timeout)
/**
* @brief Suspends the invoking thread until the system time arrives to the
diff --git a/os/nil/src/nil.c b/os/nil/src/nil.c
index c1a522d02..9254acbc0 100644
--- a/os/nil/src/nil.c
+++ b/os/nil/src/nil.c
@@ -189,7 +189,7 @@ void chSysTimerHandlerI(void) {
if (tp->timeout > (systime_t)0) {
chDbgAssert(!NIL_THD_IS_READY(tp), "is ready");
- chDbgAssert(tp->timeout >= nil.nexttime - nil.lasttime, "skipped one");
+ chDbgAssert(tp->timeout >= (nil.nexttime - nil.lasttime), "skipped one");
tp->timeout -= nil.nexttime - nil.lasttime;
if (tp->timeout == (systime_t)0) {
@@ -381,8 +381,9 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t timeout) {
/* TIMEDELTA makes sure to have enough time to reprogram the timer
before the free-running timer counter reaches the selected timeout.*/
- if (timeout < NIL_CFG_ST_TIMEDELTA)
- timeout = NIL_CFG_ST_TIMEDELTA;
+ if (timeout < (systime_t)NIL_CFG_ST_TIMEDELTA) {
+ timeout = (systime_t)NIL_CFG_ST_TIMEDELTA;
+ }
/* Absolute time of the timeout event.*/
abstime = chVTGetSystemTimeX() + timeout;
@@ -485,7 +486,7 @@ void chThdResumeI(thread_reference_t *trp, msg_t msg) {
void chThdSleep(systime_t timeout) {
chSysLock();
- (void) chThdSleepS(timeout);
+ chThdSleepS(timeout);
chSysUnlock();
}
diff --git a/os/nil/templates/nilconf.h b/os/nil/templates/nilconf.h
index 934deca8b..c89fd61aa 100644
--- a/os/nil/templates/nilconf.h
+++ b/os/nil/templates/nilconf.h
@@ -40,7 +40,7 @@
* @note This number is not inclusive of the idle thread which is
* Implicitly handled.
*/
-#define NIL_CFG_NUM_THREADS 3
+#define NIL_CFG_NUM_THREADS 1
/** @} */
diff --git a/os/nil/templates/nilcore.h b/os/nil/templates/nilcore.h
index f65d648e0..b2b71ce48 100644
--- a/os/nil/templates/nilcore.h
+++ b/os/nil/templates/nilcore.h
@@ -118,16 +118,18 @@ typedef uint64_t stkalign_t;
* preemption-capable interrupt handler.
*/
struct port_extctx {
-
+ uint32_t reg1;
+ uint32_t reg2;
};
/**
* @brief System saved context.
* @details This structure represents the inner stack frame during a context
- * switching.
+ * switch.
*/
struct port_intctx {
-
+ uint32_t reg3;
+ uint32_t reg4;
};
#endif /* !defined(_FROM_ASM_) */
@@ -141,8 +143,12 @@ struct port_intctx {
* @details This code usually setup the context switching frame represented
* by an @p port_intctx structure.
*/
-#define PORT_SETUP_CONTEXT(tp, wend, pf, arg) { \
-}
+#define PORT_SETUP_CONTEXT(tp, wend, pf, arg) do { \
+ (void)(tp); \
+ (void)(wend); \
+ (void)(pf); \
+ (void)(arg); \
+} while (false)
/**
* @brief Computes the thread working area global size.
@@ -150,7 +156,8 @@ struct port_intctx {
*/
#define PORT_WA_SIZE(n) (sizeof(struct port_intctx) + \
sizeof(struct port_extctx) + \
- (n) + (PORT_INT_REQUIRED_STACK))
+ (size_t)(n) + \
+ (size_t)(PORT_INT_REQUIRED_STACK))
/**
* @brief IRQ prologue code.
@@ -190,7 +197,11 @@ struct port_intctx {
* @param[in] ntp the thread to be switched in
* @param[in] otp the thread to be switched out
*/
-#define port_switch(ntp, otp) _port_switch(ntp, otp)
+#define port_switch(ntp, otp) do { \
+ (void)ntp; \
+ (void)otp; \
+ /*_port_switch(ntp, otp)*/ \
+} while (false)
/*===========================================================================*/
/* External declarations. */
@@ -234,7 +245,7 @@ static inline void port_init(void) {
*/
static inline syssts_t port_get_irq_status(void) {
- return 0;
+ return (syssts_t)0;
}
/**
@@ -248,6 +259,8 @@ static inline syssts_t port_get_irq_status(void) {
*/
static inline bool port_irq_enabled(syssts_t sts) {
+ (void)sts;
+
return false;
}
@@ -330,7 +343,7 @@ static inline void port_wait_for_interrupt(void) {
*/
static inline rtcnt_t port_rt_get_counter_value(void) {
- return 0;
+ return (rtcnt_t)0;
}
#endif /* !defined(_FROM_ASM_) */
@@ -342,11 +355,11 @@ static inline rtcnt_t port_rt_get_counter_value(void) {
#if !defined(_FROM_ASM_)
#if NIL_CFG_ST_TIMEDELTA > 0
-#if !PORT_USE_ALT_TIMER
+#if PORT_USE_ALT_TIMER == FALSE
#include "nilcore_timer.h"
-#else /* PORT_USE_ALT_TIMER */
+#else
#include "nilcore_timer_alt.h"
-#endif /* PORT_USE_ALT_TIMER */
+#endif
#endif /* NIL_CFG_ST_TIMEDELTA > 0 */
#endif /* !defined(_FROM_ASM_) */
diff --git a/os/nil/templates/nilcore_timer.h b/os/nil/templates/nilcore_timer.h
new file mode 100644
index 000000000..49c59309b
--- /dev/null
+++ b/os/nil/templates/nilcore_timer.h
@@ -0,0 +1,120 @@
+/*
+ ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio.
+
+ This file is part of ChibiOS.
+
+ ChibiOS 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 is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file templates/nilcore_timer.h
+ * @brief System timer header file.
+ *
+ * @addtogroup ARMCMx_TIMER
+ * @{
+ */
+
+#ifndef _NILCORE_TIMER_H_
+#define _NILCORE_TIMER_H_
+
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Starts the alarm.
+ * @note Makes sure that no spurious alarms are triggered after
+ * this call.
+ *
+ * @param[in] abstime the time to be set for the first alarm
+ *
+ * @notapi
+ */
+static inline void port_timer_start_alarm(systime_t abstime) {
+
+ (void)abstime;
+}
+
+/**
+ * @brief Stops the alarm interrupt.
+ *
+ * @notapi
+ */
+static inline void port_timer_stop_alarm(void) {
+
+}
+
+/**
+ * @brief Sets the alarm time.
+ *
+ * @param[in] abstime the time to be set for the next alarm
+ *
+ * @notapi
+ */
+static inline void port_timer_set_alarm(systime_t abstime) {
+
+ (void)abstime;
+}
+
+/**
+ * @brief Returns the system time.
+ *
+ * @return The system time.
+ *
+ * @notapi
+ */
+static inline systime_t port_timer_get_time(void) {
+
+ return (systime_t)0;
+}
+
+/**
+ * @brief Returns the current alarm time.
+ *
+ * @return The currently set alarm time.
+ *
+ * @notapi
+ */
+static inline systime_t port_timer_get_alarm(void) {
+
+ return (systime_t)0;
+}
+
+#endif /* _NILCORE_TIMER_H_ */
+
+/** @} */
diff --git a/os/nil/templates/niltypes.h b/os/nil/templates/niltypes.h
index e1e46018e..16043831b 100644
--- a/os/nil/templates/niltypes.h
+++ b/os/nil/templates/niltypes.h
@@ -46,7 +46,7 @@
* @brief Generic 'true' boolean constant.
*/
#if !defined(TRUE) || defined(__DOXYGEN__)
-#define TRUE (!FALSE)
+#define TRUE 1
#endif
/** @} */