git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8214 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2015-08-15 08:56:56 +00:00
parent a2b33f2323
commit f52c062a19
11 changed files with 300 additions and 7 deletions

View File

@ -55,7 +55,7 @@
* @brief System time counter resolution.
* @note Allowed values are 16 or 32 bits.
*/
#define NIL_CFG_ST_RESOLUTION 32
#define NIL_CFG_ST_RESOLUTION 16
/**
* @brief System tick frequency.
@ -63,7 +63,7 @@
* option defines the maximum amount of time allowed for
* timeouts.
*/
#define NIL_CFG_ST_FREQUENCY 50000
#define NIL_CFG_ST_FREQUENCY 1000
/**
* @brief Time delta constant for the tick-less mode.

View File

@ -38,7 +38,7 @@ PROJECT_NAME = ChibiOS/NIL
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 1.0.0
PROJECT_NUMBER = 1.1.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@ -38,7 +38,7 @@ PROJECT_NAME = ChibiOS/NIL
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 1.0.0
PROJECT_NUMBER = 1.1.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@ -344,6 +344,52 @@ typedef struct {
#define OSAL_US2ST(usec) US2ST(usec)
/** @} */
/**
* @name Time conversion utilities for the realtime counter
* @{
*/
/**
* @brief Seconds to realtime counter.
* @details Converts from seconds to realtime counter cycles.
* @note The macro assumes that @p freq >= @p 1.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] sec number of seconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_S2RTC(freq, sec) S2RTC(freq, sec)
/**
* @brief Milliseconds to realtime counter.
* @details Converts from milliseconds to realtime counter cycles.
* @note The result is rounded upward to the next millisecond boundary.
* @note The macro assumes that @p freq >= @p 1000.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] msec number of milliseconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_MS2RTC(freq, msec) MS2RTC(freq, msec)
/**
* @brief Microseconds to realtime counter.
* @details Converts from microseconds to realtime counter cycles.
* @note The result is rounded upward to the next microsecond boundary.
* @note The macro assumes that @p freq >= @p 1000000.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] usec number of microseconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_US2RTC(freq, usec) US2RTC(freq, usec)
/** @} */
/**
* @name Sleep macros using absolute time
* @{

View File

@ -443,6 +443,52 @@ typedef struct {
((uint32_t)OSAL_ST_FREQUENCY) + 999999UL) / 1000000UL))
/** @} */
/**
* @name Time conversion utilities for the realtime counter
* @{
*/
/**
* @brief Seconds to realtime counter.
* @details Converts from seconds to realtime counter cycles.
* @note The macro assumes that @p freq >= @p 1.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] sec number of seconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_S2RTC(freq, sec) ((freq) * (sec))
/**
* @brief Milliseconds to realtime counter.
* @details Converts from milliseconds to realtime counter cycles.
* @note The result is rounded upward to the next millisecond boundary.
* @note The macro assumes that @p freq >= @p 1000.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] msec number of milliseconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_MS2RTC(freq, msec) (rtcnt_t)((((freq) + 999UL) / 1000UL) * (msec))
/**
* @brief Microseconds to realtime counter.
* @details Converts from microseconds to realtime counter cycles.
* @note The result is rounded upward to the next microsecond boundary.
* @note The macro assumes that @p freq >= @p 1000000.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] usec number of microseconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_US2RTC(freq, usec) (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec))
/** @} */
/**
* @name Sleep macros using absolute time
* @{

View File

@ -336,6 +336,52 @@ typedef struct {
#define OSAL_US2ST(usec) US2ST(usec)
/** @} */
/**
* @name Time conversion utilities for the realtime counter
* @{
*/
/**
* @brief Seconds to realtime counter.
* @details Converts from seconds to realtime counter cycles.
* @note The macro assumes that @p freq >= @p 1.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] sec number of seconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_S2RTC(freq, sec) S2RTC(freq, sec)
/**
* @brief Milliseconds to realtime counter.
* @details Converts from milliseconds to realtime counter cycles.
* @note The result is rounded upward to the next millisecond boundary.
* @note The macro assumes that @p freq >= @p 1000.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] msec number of milliseconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_MS2RTC(freq, msec) MS2RTC(freq, msec)
/**
* @brief Microseconds to realtime counter.
* @details Converts from microseconds to realtime counter cycles.
* @note The result is rounded upward to the next microsecond boundary.
* @note The macro assumes that @p freq >= @p 1000000.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] usec number of microseconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_US2RTC(freq, usec) US2RTC(freq, usec)
/** @} */
/**
* @name Sleep macros using absolute time
* @{

View File

@ -362,6 +362,52 @@ typedef struct {
((uint32_t)OSAL_ST_FREQUENCY)) - 1UL) / 1000000UL) + 1UL))
/** @} */
/**
* @name Time conversion utilities for the realtime counter
* @{
*/
/**
* @brief Seconds to realtime counter.
* @details Converts from seconds to realtime counter cycles.
* @note The macro assumes that @p freq >= @p 1.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] sec number of seconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_S2RTC(freq, sec) ((freq) * (sec))
/**
* @brief Milliseconds to realtime counter.
* @details Converts from milliseconds to realtime counter cycles.
* @note The result is rounded upward to the next millisecond boundary.
* @note The macro assumes that @p freq >= @p 1000.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] msec number of milliseconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_MS2RTC(freq, msec) (rtcnt_t)((((freq) + 999UL) / 1000UL) * (msec))
/**
* @brief Microseconds to realtime counter.
* @details Converts from microseconds to realtime counter cycles.
* @note The result is rounded upward to the next microsecond boundary.
* @note The macro assumes that @p freq >= @p 1000000.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] usec number of microseconds
* @return The number of cycles.
*
* @api
*/
#define OSAL_US2RTC(freq, usec) (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec))
/** @} */
/**
* @name Sleep macros using absolute time
* @{

View File

@ -61,7 +61,7 @@ typedef struct nil_thread thread_t;
/**
* @brief Kernel version string.
*/
#define CH_KERNEL_VERSION "1.0.0"
#define CH_KERNEL_VERSION "1.1.0"
/**
* @brief Kernel version major number.
@ -71,7 +71,7 @@ typedef struct nil_thread thread_t;
/**
* @brief Kernel version minor number.
*/
#define CH_KERNEL_MINOR 0
#define CH_KERNEL_MINOR 1
/**
* @brief Kernel version patch number.
@ -636,10 +636,70 @@ struct nil_system {
((uint32_t)NIL_CFG_ST_FREQUENCY)) + 999999UL) / 1000000UL))
/** @} */
/**
* @name Time conversion utilities for the realtime counter
* @{
*/
/**
* @brief Seconds to realtime counter.
* @details Converts from seconds to realtime counter cycles.
* @note The macro assumes that @p freq >= @p 1.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] sec number of seconds
* @return The number of cycles.
*
* @api
*/
#define S2RTC(freq, sec) ((freq) * (sec))
/**
* @brief Milliseconds to realtime counter.
* @details Converts from milliseconds to realtime counter cycles.
* @note The result is rounded upward to the next millisecond boundary.
* @note The macro assumes that @p freq >= @p 1000.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] msec number of milliseconds
* @return The number of cycles.
*
* @api
*/
#define MS2RTC(freq, msec) (rtcnt_t)((((freq) + 999UL) / 1000UL) * (msec))
/**
* @brief Microseconds to realtime counter.
* @details Converts from microseconds to realtime counter cycles.
* @note The result is rounded upward to the next microsecond boundary.
* @note The macro assumes that @p freq >= @p 1000000.
*
* @param[in] freq clock frequency, in Hz, of the realtime counter
* @param[in] usec number of microseconds
* @return The number of cycles.
*
* @api
*/
#define US2RTC(freq, usec) (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec))
/** @} */
/**
* @name Macro Functions
* @{
*/
/**
* @brief Returns the current value of the system real time counter.
* @note This function is only available if the port layer supports the
* option @p PORT_SUPPORTS_RT.
*
* @return The value of the system realtime counter of
* type rtcnt_t.
*
* @xclass
*/
#if (PORT_SUPPORTS_RT == TRUE) || defined(__DOXYGEN__)
#define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value()
#endif
/**
* @brief Enters the kernel lock mode.
*
@ -912,6 +972,8 @@ extern "C" {
void chSysUnconditionalLock(void);
void chSysUnconditionalUnlock(void);
syssts_t chSysGetStatusAndLockX(void);
bool chSysIsCounterWithinX(rtcnt_t cnt, rtcnt_t start, rtcnt_t end);
void chSysPolledDelayX(rtcnt_t cycles);
void chSysRestoreStatusX(syssts_t sts);
thread_t *chSchReadyI(thread_t *tp, msg_t msg);
void chSchRescheduleS(void);

View File

@ -35,7 +35,7 @@
/**
* @brief This port supports a realtime counter.
*/
#define PORT_SUPPORTS_RT FALSE //TRUE
#define PORT_SUPPORTS_RT TRUE
/**
* @brief Disabled value for BASEPRI register.

View File

@ -306,6 +306,50 @@ void chSysRestoreStatusX(syssts_t sts) {
}
}
#if (PORT_SUPPORTS_RT == TRUE) || defined(__DOXYGEN__)
/**
* @brief Realtime window test.
* @details This function verifies if the current realtime counter value
* lies within the specified range or not. The test takes care
* of the realtime counter wrapping to zero on overflow.
* @note When start==end then the function returns always true because the
* whole time range is specified.
* @note This function is only available if the port layer supports the
* option @p PORT_SUPPORTS_RT.
*
* @param[in] cnt the counter value to be tested
* @param[in] start the start of the time window (inclusive)
* @param[in] end the end of the time window (non inclusive)
* @retval true current time within the specified time window.
* @retval false current time not within the specified time window.
*
* @xclass
*/
bool chSysIsCounterWithinX(rtcnt_t cnt, rtcnt_t start, rtcnt_t end) {
return (bool)((cnt - start) < (end - start));
}
/**
* @brief Polled delay.
* @note The real delay is always few cycles in excess of the specified
* value.
* @note This function is only available if the port layer supports the
* option @p PORT_SUPPORTS_RT.
*
* @param[in] cycles number of cycles
*
* @xclass
*/
void chSysPolledDelayX(rtcnt_t cycles) {
rtcnt_t start = chSysGetRealtimeCounterX();
rtcnt_t end = start + cycles;
while (chSysIsCounterWithinX(chSysGetRealtimeCounterX(), start, end)) {
}
}
#endif /* PORT_SUPPORTS_RT == TRUE */
/**
* @brief Makes the specified thread ready for execution.
*

View File

@ -74,6 +74,7 @@
*****************************************************************************
*** 3.1.0 ***
- NIL: Added polled delays required to fix bug #629.
- HAL: Added support for I2C3 and I2C4 to the STM32 I2Cv2 I2C driver.
- HAL: Added support for SPI4...SPI6 to the STM32 SPIv2 SPI driver.
- HAL: Added support for UART4...UART8 to the STM32 UARTv2 UART driver.
@ -94,6 +95,8 @@
- HAL: Introduced support for TIM21 and TIM22 in STM32 ST driver.
- HAL: Updated STM32F0xx headers to STM32CubeF0 version 1.3.0. Added support
for STM32F030xC, STM32F070x6, STM32F070xB devices.
- HAL: Fixed STM32F3xx ADC driver uses US2RTC directly (bug #629)(backported
to 3.0.2).
- HAL: Fixed CEC clock cannot be disabled on STM32F0xx (bug #628)
(backported to 3.0.1).
- VAR: Fixed lwIP arch code breaks with a 16-bit systick timer (bug #627)