aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-02-26 09:29:02 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-02-26 09:29:02 +0000
commit50439eed0df5c61ecb70483ad7d999f0038f1b3d (patch)
tree017bb6e6d51502856b80d3c16e6ffb1a44548580 /os
parent4a03cef983fcf64c8b6fbdc888dfe4b05915425e (diff)
downloadChibiOS-50439eed0df5c61ecb70483ad7d999f0038f1b3d.tar.gz
ChibiOS-50439eed0df5c61ecb70483ad7d999f0038f1b3d.tar.bz2
ChibiOS-50439eed0df5c61ecb70483ad7d999f0038f1b3d.zip
Added back missing revisions in trunk.
git-svn-id: https://svn.code.sf.net/p/chibios/svn2/trunk@11544 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os')
-rw-r--r--os/hal/include/hal.h1
-rw-r--r--os/hal/include/hal_objects.h86
-rw-r--r--os/hal/include/hal_pal.h51
-rw-r--r--os/hal/include/hal_streams.h6
-rw-r--r--os/hal/ports/SAMA/SAMA5D2x/hal_st_lld.c151
-rw-r--r--os/hal/ports/SAMA/SAMA5D2x/hal_st_lld.h97
-rw-r--r--os/hal/ports/STM32/STM32L4xx/hal_lld.h2
-rw-r--r--os/hal/ports/simulator/console.c1
-rw-r--r--os/hal/src/hal_pal.c51
-rw-r--r--os/hal/src/hal_serial.c1
-rw-r--r--os/hal/src/hal_serial_usb.c1
11 files changed, 332 insertions, 116 deletions
diff --git a/os/hal/include/hal.h b/os/hal/include/hal.h
index 337f85f6f..6eb7ccfb8 100644
--- a/os/hal/include/hal.h
+++ b/os/hal/include/hal.h
@@ -114,6 +114,7 @@
#include "hal_lld.h"
/* Abstract interfaces.*/
+#include "hal_objects.h"
#include "hal_streams.h"
#include "hal_channels.h"
#include "hal_files.h"
diff --git a/os/hal/include/hal_objects.h b/os/hal/include/hal_objects.h
new file mode 100644
index 000000000..59c3884da
--- /dev/null
+++ b/os/hal/include/hal_objects.h
@@ -0,0 +1,86 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 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 hal_objects.h
+ * @brief Base object.
+ * @details This header defines a base object that is the root for the
+ * inheritance system.
+ *
+ * @addtogroup HAL_BASE_OBJECT
+ * @details HAL uses concepts of Object Oriented Programming even if it
+ * is written in C. Things like simple inheritance, multiple
+ * inheritance and interfaces are used through the system.
+ * This module defines a "base object" that is the ancestor of
+ * all classes in the system.
+ * @{
+ */
+
+#ifndef HAL_OBJECTS_H
+#define HAL_OBJECTS_H
+
+/**
+ * @brief @p BaseObject specific methods.
+ * @note This object defines no methods.
+ */
+#define _base_object_methods \
+ /* Instance offset, used for multiple inheritance, normally zero. It
+ represents the offset between the current object and the container
+ object*/ \
+ size_t instance_offset;
+
+/**
+ * @brief @p BaseObject specific data.
+ * @note This object defines no data.
+ */
+#define _base_object_data
+
+/**
+ * @brief @p BaseObject virtual methods table.
+ */
+struct BaseObjectVMT {
+ _base_object_methods
+};
+
+/**
+ * @brief Base stream class.
+ * @details This class represents a generic blocking unbuffered sequential
+ * data stream.
+ */
+typedef struct {
+ /** @brief Virtual Methods Table.*/
+ const struct BaseObjectVMT *vmt;
+ _base_object_data
+} BaseObject;
+
+/**
+ * @name Macro Functions (BaseObject)
+ * @{
+ */
+/**
+ * @brief Returns the instance pointer starting from an interface pointer.
+ *
+ * @param[in] type the type of the instance pointer, it is used for casting
+ * @param[in] ip the interface pointer
+ * @return A pointer to the object implementing the interface
+ */
+#define objGetInstance(type, ip) \
+ (type)(((size_t)(ip)) - (ip)->vmt->instance_offset)
+/** @} */
+
+#endif /* HAL_OBJECTS_H */
+
+/** @} */
diff --git a/os/hal/include/hal_pal.h b/os/hal/include/hal_pal.h
index a3c9818ce..86a4fe699 100644
--- a/os/hal/include/hal_pal.h
+++ b/os/hal/include/hal_pal.h
@@ -949,54 +949,6 @@ typedef struct {
} while (false)
#endif /* PAL_USE_CALLBACKS == TRUE */
-#if (PAL_USE_WAIT == TRUE) || defined(__DOXYGEN__)
-/**
- * @brief Waits for an edge on the specified port/pad.
- *
- * @param[in] port port identifier
- * @param[in] pad pad number within the port
- * @param[in] timeout the number of ticks before the operation timeouts,
- * the following special values are allowed:
- * - @a TIME_IMMEDIATE immediate timeout.
- * - @a TIME_INFINITE no timeout.
- * .
- * @returns The operation state.
- * @retval MSG_OK if an edge has been detected.
- * @retval MSG_TIMEOUT if a timeout occurred before an edge cound be detected.
- * @retval MSG_RESET if the event has been disabled while the thread was
- * waiting for an edge.
- *
- * @api
- */
-#define palWaitPadTimeout(port, pad, timeout) \
- do { \
- osalSysLock(); \
- palWaitPadTimeoutS(port, pad, timeout); \
- osalSysUnlock(); \
- } while (false)
-
-
-/**
- * @brief Waits for an edge on the specified line.
- *
- * @param[in] line line identifier
- * @param[in] timeout operation timeout
- * @returns The operation state.
- * @retval MSG_OK if an edge has been detected.
- * @retval MSG_TIMEOUT if a timeout occurred before an edge cound be detected.
- * @retval MSG_RESET if the event has been disabled while the thread was
- * waiting for an edge.
- *
- * @api
- */
-#define palWaitLineTimeout(line, timeout) \
- do { \
- osalSysLock(); \
- palWaitLineTimeoutS(line, timeout); \
- osalSysUnlock(); \
- } while (false)
-#endif /* PAL_USE_WAIT == TRUE */
-
/** @} */
/*===========================================================================*/
@@ -1017,7 +969,10 @@ extern "C" {
#if (PAL_USE_WAIT == TRUE) || defined(__DOXYGEN__)
msg_t palWaitPadTimeoutS(ioportid_t port, iopadid_t pad,
sysinterval_t timeout);
+ msg_t palWaitPadTimeout(ioportid_t port, iopadid_t pad,
+ sysinterval_t timeout);
msg_t palWaitLineTimeoutS(ioline_t line, sysinterval_t timeout);
+ msg_t palWaitLineTimeout(ioline_t line, sysinterval_t timeout);
#endif /* PAL_USE_WAIT == TRUE */
#ifdef __cplusplus
}
diff --git a/os/hal/include/hal_streams.h b/os/hal/include/hal_streams.h
index 3e414ae04..bbdc65309 100644
--- a/os/hal/include/hal_streams.h
+++ b/os/hal/include/hal_streams.h
@@ -48,6 +48,7 @@
* @brief BaseSequentialStream specific methods.
*/
#define _base_sequential_stream_methods \
+ _base_object_methods \
/* Stream write buffer method.*/ \
size_t (*write)(void *instance, const uint8_t *bp, size_t n); \
/* Stream read buffer method.*/ \
@@ -62,7 +63,8 @@
* @note It is empty because @p BaseSequentialStream is only an interface
* without implementation.
*/
-#define _base_sequential_stream_data
+#define _base_sequential_stream_data \
+ _base_object_data
/**
* @brief @p BaseSequentialStream virtual methods table.
@@ -72,6 +74,8 @@ struct BaseSequentialStreamVMT {
};
/**
+ * @extends BaseObject
+ *
* @brief Base stream class.
* @details This class represents a generic blocking unbuffered sequential
* data stream.
diff --git a/os/hal/ports/SAMA/SAMA5D2x/hal_st_lld.c b/os/hal/ports/SAMA/SAMA5D2x/hal_st_lld.c
index 8d286884e..83bf6e52e 100644
--- a/os/hal/ports/SAMA/SAMA5D2x/hal_st_lld.c
+++ b/os/hal/ports/SAMA/SAMA5D2x/hal_st_lld.c
@@ -31,7 +31,7 @@
/**
* @brief Periodic Interrupt Timer frequency.
*/
-#define SAMA_PIT (SAMA_MCK / 16 / SAMA_H64MX_H32MX_RATIO)
+#define SAMA_PIT (SAMA_MCK / 16 / SAMA_H64MX_H32MX_RATIO)
#if (SAMA_ST_USE_TC0 == TRUE) || (SAMA_ST_USE_TC1 == TRUE)
/**
@@ -57,6 +57,26 @@
}
#endif
+#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
+
+#if SAMA_ST_USE_PIT
+#error "PIT timer doesn't support tick-less mode"
+#endif
+
+#if SAMA_ST_USE_TC0
+#if ((SAMA_TC0CLK) / (OSAL_ST_FREQUENCY) != 32)
+#error "Bad OSAL_ST_FREQUENCY value in configuration. It must be set to TC0_periph_clk / 32"
+#endif
+#endif
+
+#if SAMA_ST_USE_TC1
+#if ((SAMA_TC1CLK) / (OSAL_ST_FREQUENCY) != 32)
+#error "Bad OSAL_ST_FREQUENCY value in configuration. It must be set to TC1_periph_clk / 32"
+#endif
+#endif
+
+#endif
+
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
@@ -69,6 +89,10 @@
/* Driver local variables and types. */
/*===========================================================================*/
+#if SAMA_ST_USE_TC0 || SAMA_ST_USE_TC1
+static Tc *tcp;
+#endif
+
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
@@ -77,39 +101,27 @@
/* Driver interrupt handlers. */
/*===========================================================================*/
-#if (OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC) || defined(__DOXYGEN__)
-
-#if (SAMA_ST_USE_TC0)
-OSAL_IRQ_HANDLER(SAMA_ST_TC0_HANDLER) {
-
- OSAL_IRQ_PROLOGUE();
- if (((TC0->TC_CHANNEL[0].TC_SR & TC_SR_CPCS) != 0) &&
- ((TC0->TC_CHANNEL[0].TC_IMR & TC_IMR_CPCS) != 0)) {
- osalSysLockFromISR();
- osalOsTimerHandlerI();
- osalSysUnlockFromISR();
- }
- aicAckInt();
- OSAL_IRQ_EPILOGUE();
-}
-#endif
-
-#if (SAMA_ST_USE_TC1)
-OSAL_IRQ_HANDLER(SAMA_ST_TC1_HANDLER) {
+#if (SAMA_ST_USE_TC0 || SAMA_ST_USE_TC1) || defined(__DOXYGEN__)
+/**
+ * @brief System Timer vector.
+ * @details This interrupt is used for system tick in periodic or free running
+ * mode, generated by TCx timer
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(SAMA_ST_TC_HANDLER) {
OSAL_IRQ_PROLOGUE();
- if (((TC1->TC_CHANNEL[0].TC_SR & TC_SR_CPCS) != 0) &&
- ((TC1->TC_CHANNEL[0].TC_IMR & TC_IMR_CPCS) != 0)) {
- osalSysLockFromISR();
- osalOsTimerHandlerI();
- osalSysUnlockFromISR();
- }
+ (void)tcp->TC_CHANNEL[0].TC_SR; /* acknowledge TC interrupt */
+ osalSysLockFromISR();
+ osalOsTimerHandlerI();
+ osalSysUnlockFromISR();
aicAckInt();
OSAL_IRQ_EPILOGUE();
}
#endif
-#if (SAMA_ST_USE_PIT == TRUE)
+#if (SAMA_ST_USE_PIT) || defined(__DOXYGEN__)
/**
* @brief System Timer vector.
* @details This interrupt is used for system tick in periodic mode.
@@ -131,8 +143,6 @@ OSAL_IRQ_HANDLER(PIT_Handler) {
}
#endif /* SAMA_ST_USE_PIT == TRUE */
-#endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */
-
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
@@ -144,72 +154,81 @@ OSAL_IRQ_HANDLER(PIT_Handler) {
*/
void st_lld_init(void) {
-#if (OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC)
+#if SAMA_ST_USE_TC0 || SAMA_ST_USE_TC1
+
+#if SAMA_ST_USE_TC0
+ tcp = TC0;
+ uint32_t rc = (SAMA_TC0CLK) / (OSAL_ST_FREQUENCY);
-#if (SAMA_ST_USE_TC0 == TRUE)
#if SAMA_HAL_IS_SECURE
mtxConfigPeriphSecurity(MATRIX1, ID_TC0, SECURE_PER);
#endif /* SAMA_HAL_IS_SECURE */
+
pmcEnableTC0();
aicSetSourcePriority(ID_TC0, SAMA_TC0_IRQ_PRIORITY);
- aicSetSourceHandler(ID_TC0, SAMA_ST_TC0_HANDLER);
+ aicSetSourceHandler(ID_TC0, SAMA_ST_TC_HANDLER);
aicEnableInt(ID_TC0);
+#endif
+
+#if SAMA_ST_USE_TC1
+ tcp = TC1;
+ uint32_t rc = (SAMA_TC1CLK) / (OSAL_ST_FREQUENCY);
- tcDisableWP(TC0);
- uint32_t rc = (SAMA_TC0CLK) / (OSAL_ST_FREQUENCY);
- TC0->TC_CHANNEL[0].TC_EMR = TC_EMR_NODIVCLK;
- TC0->TC_CHANNEL[0].TC_CMR = TC_CMR_WAVE | TC_CMR_ACPA_SET |
- TC_CMR_ACPC_CLEAR | TC_CMR_WAVSEL_UP_RC;
- TC0->TC_CHANNEL[0].TC_RC = TC_RC_RC(rc);
- TC0->TC_CHANNEL[0].TC_RA = TC_RA_RA(rc);
- TC0->TC_CHANNEL[0].TC_CCR = TC_CCR_CLKEN;
- TC0->TC_CHANNEL[0].TC_CCR = TC_CCR_SWTRG;
- TC0->TC_CHANNEL[0].TC_SR; /* Clear pending IRQs. */
- TC0->TC_CHANNEL[0].TC_IER |= TC_IER_CPCS;
- tcEnableWP(TC0);
-#endif /* SAMA_ST_USE_TC0 == TRUE */
-
-#if (SAMA_ST_USE_TC1 == TRUE)
#if SAMA_HAL_IS_SECURE
mtxConfigPeriphSecurity(MATRIX1, ID_TC1, SECURE_PER);
#endif /* SAMA_HAL_IS_SECURE */
+
pmcEnableTC1();
aicSetSourcePriority(ID_TC1, SAMA_TC1_IRQ_PRIORITY);
- aicSetSourceHandler(ID_TC1, SAMA_ST_TC1_HANDLER);
+ aicSetSourceHandler(ID_TC1, SAMA_ST_TC_HANDLER);
aicEnableInt(ID_TC1);
+#endif
- tcDisableWP(TC1);
- uint32_t rc = (SAMA_TC1CLK) / (OSAL_ST_FREQUENCY);
- TC1->TC_CHANNEL[0].TC_EMR = TC_EMR_NODIVCLK;
- TC1->TC_CHANNEL[0].TC_CMR = TC_CMR_WAVE | TC_CMR_ACPA_SET |
- TC_CMR_ACPC_CLEAR | TC_CMR_WAVSEL_UP_RC;
- TC1->TC_CHANNEL[0].TC_RC = TC_RC_RC(rc);
- TC1->TC_CHANNEL[0].TC_RA = TC_RA_RA(rc);
- TC1->TC_CHANNEL[0].TC_CCR = TC_CCR_CLKEN;
- TC1->TC_CHANNEL[0].TC_CCR = TC_CCR_SWTRG;
- TC1->TC_CHANNEL[0].TC_SR; /* Clear pending IRQs. */
- TC1->TC_CHANNEL[0].TC_IER |= TC_IER_CPCS;
- tcEnableWP(TC1);
-#endif /* SAMA_ST_USE_TC1 == TRUE */
+ tcDisableWP(tcp);
+
+#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
+
+ /* Initializing the timer counter in free running mode.
+ * The clock source is the bus clock divided by 32.*/
+ (void)rc;
+ tcp->TC_CHANNEL[0].TC_EMR = 0;
+ tcp->TC_CHANNEL[0].TC_CMR = TC_CMR_WAVE | TC_CMR_WAVSEL_UP |
+ TC_CMR_TCCLKS(TC_CMR_TCCLKS_TIMER_CLOCK3);
+ tcp->TC_CHANNEL[0].TC_RC = 0;
+ tcp->TC_CHANNEL[0].TC_CCR = TC_CCR_CLKEN | TC_CCR_SWTRG;
+ tcp->TC_CHANNEL[0].TC_IDR = 0xFFFFFFFF; /* Disable IRQs. */
+ tcp->TC_CHANNEL[0].TC_SR; /* Clear pending IRQs. */
+#endif
+
+#if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC
+ tcp->TC_CHANNEL[0].TC_EMR = TC_EMR_NODIVCLK;
+ tcp->TC_CHANNEL[0].TC_CMR = TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC;
+ tcp->TC_CHANNEL[0].TC_RC = TC_RC_RC(rc);
+ tcp->TC_CHANNEL[0].TC_CCR = TC_CCR_CLKEN | TC_CCR_SWTRG;;
+ tcp->TC_CHANNEL[0].TC_SR; /* Clear pending IRQs. */
+ tcp->TC_CHANNEL[0].TC_IER = TC_IER_CPCS;
+#endif
+
+ tcEnableWP(tcp);
+#endif /* SAMA_ST_USE_TC0 || SAMA_ST_USE_TC1 */
#if (SAMA_ST_USE_PIT == TRUE)
#if SAMA_HAL_IS_SECURE
mtxConfigPeriphSecurity(MATRIX1, ID_PIT, SECURE_PER);
#endif /* SAMA_HAL_IS_SECURE */
- /* Enabling PIT.*/
- pmcEnablePIT();
+ /* Enable PIT.*/
+ pmcEnablePIT();
PIT->PIT_MR = PIT_MR_PIV((SAMA_PIT / OSAL_ST_FREQUENCY) - 1);
PIT->PIT_MR |= PIT_MR_PITEN | PIT_MR_PITIEN;
(void) PIT->PIT_PIVR; /* reset PIT PICNT counter */
- /* IRQ enabled.*/
+ /* Enable IRQ.*/
aicSetSourcePriority(ID_PIT, SAMA_ST_IRQ_PRIORITY);
aicSetSourceHandler(ID_PIT, PIT_Handler);
aicEnableInt(ID_PIT);
-#endif /* SAMA_ST_USE_PIT == TRUE */
+#endif /* SAMA_ST_USE_PIT */
-#endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */
}
/** @} */
diff --git a/os/hal/ports/SAMA/SAMA5D2x/hal_st_lld.h b/os/hal/ports/SAMA/SAMA5D2x/hal_st_lld.h
index bce654bc9..3325d4ac8 100644
--- a/os/hal/ports/SAMA/SAMA5D2x/hal_st_lld.h
+++ b/os/hal/ports/SAMA/SAMA5D2x/hal_st_lld.h
@@ -95,6 +95,7 @@
#define SAMA_TC1_IS_USED
#endif
#endif
+
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
@@ -128,7 +129,22 @@ extern "C" {
*/
static inline systime_t st_lld_get_counter(void) {
+#if (SAMA_ST_USE_TC0 || SAMA_ST_USE_TC1)
+
+#if SAMA_ST_USE_TC0
+
+ Tc *tcp = TC0;
+#endif
+#if SAMA_ST_USE_TC1
+
+ Tc *tcp = TC1;
+#endif
+
+ return (systime_t)tcp->TC_CHANNEL[0].TC_CV;
+#else
+
return (systime_t)0;
+#endif
}
/**
@@ -142,7 +158,26 @@ static inline systime_t st_lld_get_counter(void) {
*/
static inline void st_lld_start_alarm(systime_t time) {
+#if (SAMA_ST_USE_TC0 || SAMA_ST_USE_TC1)
+
+#if SAMA_ST_USE_TC0
+
+ Tc *tcp = TC0;
+#endif
+#if SAMA_ST_USE_TC1
+
+ Tc *tcp = TC1;
+#endif
+
+ tcp->TC_WPMR = TC_WPMR_WPKEY_PASSWD;
+ tcp->TC_CHANNEL[0].TC_RC = TC_RC_RC((uint32_t)time);
+ tcp->TC_CHANNEL[0].TC_SR;
+ tcp->TC_CHANNEL[0].TC_IER = TC_IER_CPCS;
+ tcp->TC_WPMR = TC_WPMR_WPKEY_PASSWD | TC_WPMR_WPEN;
+#else
+
(void)time;
+#endif
}
/**
@@ -152,6 +187,21 @@ static inline void st_lld_start_alarm(systime_t time) {
*/
static inline void st_lld_stop_alarm(void) {
+#if (SAMA_ST_USE_TC0 || SAMA_ST_USE_TC1)
+
+#if SAMA_ST_USE_TC0
+
+ Tc *tcp = TC0;
+#endif
+#if SAMA_ST_USE_TC1
+
+ Tc *tcp = TC1;
+#endif
+
+ tcp->TC_WPMR = TC_WPMR_WPKEY_PASSWD;
+ tcp->TC_CHANNEL[0].TC_IDR = TC_IDR_CPCS;
+ tcp->TC_WPMR = TC_WPMR_WPKEY_PASSWD | TC_WPMR_WPEN;
+#endif
}
/**
@@ -163,7 +213,24 @@ static inline void st_lld_stop_alarm(void) {
*/
static inline void st_lld_set_alarm(systime_t time) {
+#if (SAMA_ST_USE_TC0 || SAMA_ST_USE_TC1)
+
+#if SAMA_ST_USE_TC0
+
+ Tc *tcp = TC0;
+#endif
+#if SAMA_ST_USE_TC1
+
+ Tc *tcp = TC1;
+#endif
+
+ tcp->TC_WPMR = TC_WPMR_WPKEY_PASSWD;
+ tcp->TC_CHANNEL[0].TC_RC = TC_RC_RC((uint32_t)time);
+ tcp->TC_WPMR = TC_WPMR_WPKEY_PASSWD | TC_WPMR_WPEN;
+#else
+
(void)time;
+#endif
}
/**
@@ -175,7 +242,22 @@ static inline void st_lld_set_alarm(systime_t time) {
*/
static inline systime_t st_lld_get_alarm(void) {
+#if (SAMA_ST_USE_TC0 || SAMA_ST_USE_TC1)
+
+#if SAMA_ST_USE_TC0
+
+ Tc *tcp = TC0;
+#endif
+#if SAMA_ST_USE_TC1
+
+ Tc *tcp = TC1;
+#endif
+
+ return (systime_t)tcp->TC_CHANNEL[0].TC_RC;
+#else
+
return (systime_t)0;
+#endif
}
/**
@@ -189,7 +271,22 @@ static inline systime_t st_lld_get_alarm(void) {
*/
static inline bool st_lld_is_alarm_active(void) {
+#if (SAMA_ST_USE_TC0 || SAMA_ST_USE_TC1)
+
+#if SAMA_ST_USE_TC0
+
+ Tc *tcp = TC0;
+#endif
+#if SAMA_ST_USE_TC1
+
+ Tc *tcp = TC1;
+#endif
+
+ return (bool)((tcp->TC_CHANNEL[0].TC_IMR & TC_IMR_CPCS) != 0);
+#else
+
return false;
+#endif
}
#endif /* HAL_ST_LLD_H */
diff --git a/os/hal/ports/STM32/STM32L4xx/hal_lld.h b/os/hal/ports/STM32/STM32L4xx/hal_lld.h
index a40bc2b96..3e6ac5da9 100644
--- a/os/hal/ports/STM32/STM32L4xx/hal_lld.h
+++ b/os/hal/ports/STM32/STM32L4xx/hal_lld.h
@@ -1182,7 +1182,7 @@
/*
* PLL enable check.
*/
-#if (STM32_CLK48SEL == STM32_CLK48SEL_PLL) || \
+#if (STM32_HSI48_ENABLED && (STM32_CLK48SEL == STM32_CLK48SEL_PLL)) || \
(STM32_SW == STM32_SW_PLL) || \
(STM32_MCOSEL == STM32_MCOSEL_PLL) || \
(STM32_SAI1SEL == STM32_SAI1SEL_PLL) || \
diff --git a/os/hal/ports/simulator/console.c b/os/hal/ports/simulator/console.c
index 4a0c2b44c..80b949c73 100644
--- a/os/hal/ports/simulator/console.c
+++ b/os/hal/ports/simulator/console.c
@@ -123,6 +123,7 @@ static msg_t _ctl(void *ip, unsigned int operation, void *arg) {
}
static const struct BaseChannelVMT vmt = {
+ (size_t)0,
_write, _read, _put, _get,
_putt, _gett, _writet, _readt,
_ctl
diff --git a/os/hal/src/hal_pal.c b/os/hal/src/hal_pal.c
index 1f2ced277..3861ebae3 100644
--- a/os/hal/src/hal_pal.c
+++ b/os/hal/src/hal_pal.c
@@ -181,6 +181,35 @@ msg_t palWaitPadTimeoutS(ioportid_t port,
}
/**
+ * @brief Waits for an edge on the specified port/pad.
+ *
+ * @param[in] port port identifier
+ * @param[in] pad pad number within the port
+ * @param[in] timeout the number of ticks before the operation timeouts,
+ * the following special values are allowed:
+ * - @a TIME_IMMEDIATE immediate timeout.
+ * - @a TIME_INFINITE no timeout.
+ * .
+ * @returns The operation state.
+ * @retval MSG_OK if an edge has been detected.
+ * @retval MSG_TIMEOUT if a timeout occurred before an edge cound be detected.
+ * @retval MSG_RESET if the event has been disabled while the thread was
+ * waiting for an edge.
+ *
+ * @api
+ */
+msg_t palWaitPadTimeout(ioportid_t port,
+ iopadid_t pad,
+ sysinterval_t timeout) {
+ msg_t msg;
+
+ osalSysLock();
+ msg = palWaitPadTimeoutS(port, pad, timeout);
+ osalSysUnlock();
+ return msg;
+}
+
+/**
* @brief Waits for an edge on the specified line.
*
* @param[in] line line identifier
@@ -199,6 +228,28 @@ msg_t palWaitLineTimeoutS(ioline_t line,
palevent_t *pep = pal_lld_get_line_event(line);
return osalThreadEnqueueTimeoutS(&pep->threads, timeout);
}
+
+/**
+ * @brief Waits for an edge on the specified line.
+ *
+ * @param[in] line line identifier
+ * @param[in] timeout operation timeout
+ * @returns The operation state.
+ * @retval MSG_OK if an edge has been detected.
+ * @retval MSG_TIMEOUT if a timeout occurred before an edge cound be detected.
+ * @retval MSG_RESET if the event has been disabled while the thread was
+ * waiting for an edge.
+ *
+ * @api
+ */
+msg_t palWaitLineTimeout(ioline_t line, sysinterval_t timeout) {
+ msg_t msg;
+
+ osalSysLock();
+ msg= palWaitLineTimeoutS(line, timeout);
+ osalSysUnlock();
+ return msg;
+}
#endif /* PAL_USE_WAIT == TRUE */
#endif /* HAL_USE_PAL == TRUE */
diff --git a/os/hal/src/hal_serial.c b/os/hal/src/hal_serial.c
index 734316877..d4a85d424 100644
--- a/os/hal/src/hal_serial.c
+++ b/os/hal/src/hal_serial.c
@@ -115,6 +115,7 @@ static msg_t _ctl(void *ip, unsigned int operation, void *arg) {
}
static const struct SerialDriverVMT vmt = {
+ (size_t)0,
_write, _read, _put, _get,
_putt, _gett, _writet, _readt,
_ctl
diff --git a/os/hal/src/hal_serial_usb.c b/os/hal/src/hal_serial_usb.c
index 02a61d09b..ec1f1c4fe 100644
--- a/os/hal/src/hal_serial_usb.c
+++ b/os/hal/src/hal_serial_usb.c
@@ -154,6 +154,7 @@ static msg_t _ctl(void *ip, unsigned int operation, void *arg) {
}
static const struct SerialUSBDriverVMT vmt = {
+ (size_t)0,
_write, _read, _put, _get,
_putt, _gett, _writet, _readt,
_ctl