aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/include/hal.h9
-rw-r--r--os/hal/ports/simulator/st_lld.c67
-rw-r--r--os/hal/ports/simulator/st_lld.h141
-rw-r--r--os/hal/ports/simulator/win32/hal_lld.c10
-rw-r--r--os/hal/ports/simulator/win32/platform.mk3
-rw-r--r--os/hal/ports/simulator/win32/serial_lld.c4
-rw-r--r--os/hal/ports/simulator/win32/serial_lld.h4
-rw-r--r--os/hal/src/hal.c7
8 files changed, 232 insertions, 13 deletions
diff --git a/os/hal/include/hal.h b/os/hal/include/hal.h
index c29eee17d..5fda51fef 100644
--- a/os/hal/include/hal.h
+++ b/os/hal/include/hal.h
@@ -61,10 +61,17 @@
#include "serial.h"
#include "sdc.h"
#include "spi.h"
-#include "st.h"
#include "uart.h"
#include "usb.h"
+/*
+ * The ST driver is a special case, it is only included if the OSAL is
+ * configured to require it.
+ */
+#if OSAL_ST_MODE != OSAL_ST_MODE_NONE
+#include "st.h"
+#endif
+
/* Complex drivers.*/
#include "mmc_spi.h"
#include "serial_usb.h"
diff --git a/os/hal/ports/simulator/st_lld.c b/os/hal/ports/simulator/st_lld.c
new file mode 100644
index 000000000..d6768ddf9
--- /dev/null
+++ b/os/hal/ports/simulator/st_lld.c
@@ -0,0 +1,67 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2014 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file st_lld.c
+ * @brief PLATFORM ST subsystem low level driver source.
+ *
+ * @addtogroup ST
+ * @{
+ */
+
+#include "hal.h"
+
+#if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Low level ST driver initialization.
+ *
+ * @notapi
+ */
+void st_lld_init(void) {
+}
+
+#endif /* OSAL_ST_MODE != OSAL_ST_MODE_NONE */
+
+/** @} */
diff --git a/os/hal/ports/simulator/st_lld.h b/os/hal/ports/simulator/st_lld.h
new file mode 100644
index 000000000..b5de30a6d
--- /dev/null
+++ b/os/hal/ports/simulator/st_lld.h
@@ -0,0 +1,141 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2014 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file st_lld.h
+ * @brief PLATFORM ST subsystem low level driver header.
+ * @details This header is designed to be include-able without having to
+ * include other files from the HAL.
+ *
+ * @addtogroup ST
+ * @{
+ */
+
+#ifndef _ST_LLD_H_
+#define _ST_LLD_H_
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void st_lld_init(void);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Driver inline functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Returns the time counter value.
+ *
+ * @return The counter value.
+ *
+ * @notapi
+ */
+static inline systime_t st_lld_get_counter(void) {
+
+ return (systime_t)0;
+}
+
+/**
+ * @brief Starts the alarm.
+ * @note Makes sure that no spurious alarms are triggered after
+ * this call.
+ *
+ * @param[in] time the time to be set for the first alarm
+ *
+ * @notapi
+ */
+static inline void st_lld_start_alarm(systime_t time) {
+
+ (void)time;
+}
+
+/**
+ * @brief Stops the alarm interrupt.
+ *
+ * @notapi
+ */
+static inline void st_lld_stop_alarm(void) {
+
+}
+
+/**
+ * @brief Sets the alarm time.
+ *
+ * @param[in] time the time to be set for the next alarm
+ *
+ * @notapi
+ */
+static inline void st_lld_set_alarm(systime_t time) {
+
+ (void)time;
+}
+
+/**
+ * @brief Returns the current alarm time.
+ *
+ * @return The currently set alarm time.
+ *
+ * @notapi
+ */
+static inline systime_t st_lld_get_alarm(void) {
+
+ return (systime_t)0;
+}
+
+/**
+ * @brief Determines if the alarm is active.
+ *
+ * @return The alarm status.
+ * @retval false if the alarm is not active.
+ * @retval true is the alarm is active
+ *
+ * @notapi
+ */
+static inline bool st_lld_is_alarm_active(void) {
+
+ return false;
+}
+
+#endif /* _ST_LLD_H_ */
+
+/** @} */
diff --git a/os/hal/ports/simulator/win32/hal_lld.c b/os/hal/ports/simulator/win32/hal_lld.c
index a42815c0c..555e749a0 100644
--- a/os/hal/ports/simulator/win32/hal_lld.c
+++ b/os/hal/ports/simulator/win32/hal_lld.c
@@ -64,7 +64,7 @@ void hal_lld_init(void) {
printf("QueryPerformanceFrequency() error");
exit(1);
}
- slice.QuadPart /= CH_FREQUENCY;
+ slice.QuadPart /= CH_CFG_ST_FREQUENCY;
QueryPerformanceCounter(&nextcnt);
nextcnt.QuadPart += slice.QuadPart;
@@ -79,10 +79,10 @@ void _sim_check_for_interrupts(void) {
#if HAL_USE_SERIAL
if (sd_lld_interrupt_pending()) {
- dbg_check_lock();
+ _dbg_check_lock();
if (chSchIsPreemptionRequired())
chSchDoReschedule();
- dbg_check_unlock();
+ _dbg_check_unlock();
return;
}
#endif
@@ -100,10 +100,10 @@ void _sim_check_for_interrupts(void) {
CH_IRQ_EPILOGUE();
- dbg_check_lock();
+ _dbg_check_lock();
if (chSchIsPreemptionRequired())
chSchDoReschedule();
- dbg_check_unlock();
+ _dbg_check_unlock();
}
}
diff --git a/os/hal/ports/simulator/win32/platform.mk b/os/hal/ports/simulator/win32/platform.mk
index 8136324e7..842309c62 100644
--- a/os/hal/ports/simulator/win32/platform.mk
+++ b/os/hal/ports/simulator/win32/platform.mk
@@ -1,7 +1,8 @@
# List of all the Win32 platform files.
PLATFORMSRC = ${CHIBIOS}/os/hal/ports/simulator/win32/hal_lld.c \
${CHIBIOS}/os/hal/ports/simulator/win32/serial_lld.c \
- ${CHIBIOS}/os/hal/ports/simulator/pal_lld.c
+ ${CHIBIOS}/os/hal/ports/simulator/pal_lld.c \
+ ${CHIBIOS}/os/hal/ports/simulator/st_lld.c
# Required include directories
PLATFORMINC = ${CHIBIOS}/os/hal/ports/simulator/win32 \
diff --git a/os/hal/ports/simulator/win32/serial_lld.c b/os/hal/ports/simulator/win32/serial_lld.c
index 7cf1e5b66..e33499f1f 100644
--- a/os/hal/ports/simulator/win32/serial_lld.c
+++ b/os/hal/ports/simulator/win32/serial_lld.c
@@ -133,7 +133,7 @@ static bool inint(SerialDriver *sdp) {
/*
* Input.
*/
- int n = recv(sdp->com_data, data, sizeof(data), 0);
+ int n = recv(sdp->com_data, (char *)data, sizeof(data), 0);
switch (n) {
case 0:
closesocket(sdp->com_data);
@@ -174,7 +174,7 @@ static bool outint(SerialDriver *sdp) {
if (n < 0)
return FALSE;
data[0] = (uint8_t)n;
- n = send(sdp->com_data, data, sizeof(data), 0);
+ n = send(sdp->com_data, (char *)data, sizeof(data), 0);
switch (n) {
case 0:
closesocket(sdp->com_data);
diff --git a/os/hal/ports/simulator/win32/serial_lld.h b/os/hal/ports/simulator/win32/serial_lld.h
index 22fb36b8f..ba49bd671 100644
--- a/os/hal/ports/simulator/win32/serial_lld.h
+++ b/os/hal/ports/simulator/win32/serial_lld.h
@@ -99,9 +99,9 @@ typedef struct {
/* Driver state.*/ \
sdstate_t state; \
/* Input queue.*/ \
- InputQueue iqueue; \
+ input_queue_t iqueue; \
/* Output queue.*/ \
- OutputQueue oqueue; \
+ output_queue_t oqueue; \
/* Input circular buffer.*/ \
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
/* Output circular buffer.*/ \
diff --git a/os/hal/src/hal.c b/os/hal/src/hal.c
index d9985993e..b49f7383e 100644
--- a/os/hal/src/hal.c
+++ b/os/hal/src/hal.c
@@ -122,8 +122,11 @@ void halInit(void) {
/* Board specific initialization.*/
boardInit();
-#if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__)
- /* System tick service if the underlying OS requires it.*/
+/*
+ * The ST driver is a special case, it is only initialized if the OSAL is
+ * configured to require it.
+ */
+#if OSAL_ST_MODE != OSAL_ST_MODE_NONE
stInit();
#endif
}