1)Added cputime module documentation 2)Updated OS time module: - Use os_time_advance instead of os_time_tick - Added os_get_uptime_usec - Added os_time_ms_to_ticks
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/commit/be606a2e Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/tree/be606a2e Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/diff/be606a2e Branch: refs/heads/develop Commit: be606a2e0d73b6acc8eec70000763f62968fa01a Parents: 19e0f48 Author: cwanda <[email protected]> Authored: Thu Mar 30 14:35:38 2017 -0700 Committer: cwanda <[email protected]> Committed: Thu Mar 30 15:33:46 2017 -0700 ---------------------------------------------------------------------- docs/os/core_os/cputime/os_cputime.md | 43 +++++++++++++ .../core_os/cputime/os_cputime_delay_nsecs.md | 25 ++++++++ .../core_os/cputime/os_cputime_delay_ticks.md | 25 ++++++++ .../core_os/cputime/os_cputime_delay_usecs.md | 25 ++++++++ docs/os/core_os/cputime/os_cputime_get32.md | 23 +++++++ docs/os/core_os/cputime/os_cputime_init.md | 29 +++++++++ .../cputime/os_cputime_nsecs_to_ticks.md | 24 ++++++++ .../cputime/os_cputime_ticks_to_nsecs.md | 24 ++++++++ .../cputime/os_cputime_ticks_to_usecs.md | 24 ++++++++ .../os/core_os/cputime/os_cputime_timer_init.md | 65 ++++++++++++++++++++ .../cputime/os_cputime_timer_relative.md | 33 ++++++++++ .../core_os/cputime/os_cputime_timer_start.md | 34 ++++++++++ .../os/core_os/cputime/os_cputime_timer_stop.md | 30 +++++++++ .../cputime/os_cputime_usecs_to_ticks.md | 24 ++++++++ docs/os/core_os/time/os_get_uptime_usec.md | 24 ++++++++ docs/os/core_os/time/os_time.md | 6 +- docs/os/core_os/time/os_time_advance.md | 22 +++++++ docs/os/core_os/time/os_time_ms_to_ticks.md | 29 +++++++++ docs/os/core_os/time/os_time_tick.md | 27 -------- mkdocs.yml | 22 ++++++- 20 files changed, 527 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime.md b/docs/os/core_os/cputime/os_cputime.md new file mode 100644 index 0000000..1a6ce06 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime.md @@ -0,0 +1,43 @@ +# CPU Time + +The MyNewt `cputime` module provides high resolution time and timer support. This module is intended for use by BSPs, drivers, and network controllers. + +## Description + +The `cputime` API provides high resolution time and timer support. The module must be initialized, using the `os_cputime_init()` function, with the clock frequency to use. The module uses the `hal_timer` API, defined in hal/hal_timer.h, to access the hardware timers. It uses the hardware timer number specified by the `OS_CPUTIME_TIMER_NUM` system configuration setting. + +## Data Structures + +The module uses the following data structures: + +* `uint32_t` to represent `cputime`. Only the lower 32 bits of a 64 timer are used. +* `struct hal_timer` to represent a cputime timer. + +## List of Functions + +The functions available in cputime are: + +| **Function** | **Description** | +|-----------|-----------| +| [os_cputime_delay_nsecs](os_cputime_delay_nsecs.md) | Delays for a specified number of nanoseconds. | +| [os_cputime_delay_ticks](os_cputime_delay_ticks.md) | Delays for a specified number of ticks. | +| [os_cputime_delay_usecs](os_cputime_delay_usecs.md) | Delays for a specified number of microseconds. | +| [os_cputime_get32](os_cputime_get32.md) | Gets the current value of the cpu time.| +| [os_cputime_init](os_cputime_init.md) | Initializes the cputime module. | +| [os_cputime_nsecs_to_ticks](os_cputime_nsecs_to_ticks.md) | Converts the specified number of nanoseconds to number of ticks. | +| [os_cputime_ticks_to_nsecs](os_cputime_ticks_to_nsecs.md) | Converts the specified number of ticks to number of nanoseconds. | +| [os_cputime_ticks_to_usecs](os_cputime_ticks_to_usecs.md) | Converts the specified number of ticks to number of microseconds. | +| [os_cputime_timer_init](os_cputime_timer_init.md) | Initializes a timer. | +| [os_cputime_timer_relative](os_cputime_timer_relative.md) | Sets a timer to expire in the specified number of microseconds from the current time. | +| [os_cputime_timer_start](os_cputime_timer_start.md) | Sets a timer to expire at the specified cputime. | +| [os_cputime_timer_stop](os_cputime_timer_stop.md) | Stops a timer from running. | +| [os_cputime_usecs_to_ticks](os_cputime_usecs_to_ticks.md) | Converts the specified number of microseconds to number of ticks. | + +## List of Macros + +These macros should be used to evaluate the time with respect to each other. + +* `CPUIME_LT(t1,t2)` -- evaluates to true if t1 is before t2 in time. +* `CPUTIME_GT(t1,t2)` -- evaluates to true if t1 is after t2 in time +* `CPUTIME_LEQ(t1,t2)` -- evaluates to true if t1 is on or before t2 in time. +* `CPUTIME_GEQ(t1,t2)` -- evaluates to true if t1 is on or after t2 in time. http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_delay_nsecs.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_delay_nsecs.md b/docs/os/core_os/cputime/os_cputime_delay_nsecs.md new file mode 100644 index 0000000..c4e0e71 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_delay_nsecs.md @@ -0,0 +1,25 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_delay_nsecs</font> + +```c +void os_cputime_delay_nsecs(uint32_t nsecs) +``` +Waits for a specified number of nanoseconds to elapse before returning. + + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `nsecs` | Number of nanoseconds to delay for. + + +#### Returned values +N/A + +#### Notes + +#### Example +Delays for 250000 nsecs: +```c +os_cputime_delay_nsecs(250000) +``` http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_delay_ticks.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_delay_ticks.md b/docs/os/core_os/cputime/os_cputime_delay_ticks.md new file mode 100644 index 0000000..a744141 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_delay_ticks.md @@ -0,0 +1,25 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_delay_ticks</font> + +```c +void os_cputime_delay_ticks(uint32_t ticks) +``` +Waits for a specified number of ticks to elapse before returning. + + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `ticks` | Number of ticks to delay for. + + +#### Returned values +N/A + +#### Notes + +#### Example +Delays for 100000 ticks: +```c +os_cputime_delay_ticks(100000) +``` http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_delay_usecs.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_delay_usecs.md b/docs/os/core_os/cputime/os_cputime_delay_usecs.md new file mode 100644 index 0000000..86c1b43 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_delay_usecs.md @@ -0,0 +1,25 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_delay_usecs</font> + +```c +void os_cputime_delay_usecs(uint32_t usecs) +``` +Waits for a specified number of microseconds to elapse before returning. + + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `usecs` | Number of microseconds to delay for. + + +#### Returned values +N/A + +#### Notes + +#### Example +Delays for 250000 usecs: +```c +os_cputime_delay_usecs(250000) +``` http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_get32.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_get32.md b/docs/os/core_os/cputime/os_cputime_get32.md new file mode 100644 index 0000000..b2ee2c8 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_get32.md @@ -0,0 +1,23 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_get32</font> + +```c +uint32_t os_cputime_get32(void) +``` +Gets the current cputime. If a timer is 64 bits, only the lower 32 bit is returned. + +#### Arguments +N/A + +#### Returned values + +The current cputime. + +#### Notes + +#### Example + +```c +uint32 cur_cputime; +cur_cputime = os_cputime_get32(); +``` + http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_init.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_init.md b/docs/os/core_os/cputime/os_cputime_init.md new file mode 100644 index 0000000..2e119c8 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_init.md @@ -0,0 +1,29 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_init</font> + +```c +int os_cputime_init(uint32_t clock_freq) +``` +Initializes the cputime module with the clock frequency (in HZ) to use for the timer resolution. It configures the hardware timer specified by the `OS_CPUTIME_TIMER_NUM` sysconfig value to run at the specified clock frequency. + + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `clock_freq` | Clock frequency, in HZ, for the timer resolution. + + +#### Returned values + +0 on success and -1 on error. + +#### Notes +This function must be called after os_init is called. It should only be called once and before any other timer API and hardware timers are used. + +#### Example +A BSP package usually calls this function and uses the `OS_CPUTIME_FREQUENCY` sysconfig value for the clock frequency argument: +```c +int rc +rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQUENCY)); +``` + http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_nsecs_to_ticks.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_nsecs_to_ticks.md b/docs/os/core_os/cputime/os_cputime_nsecs_to_ticks.md new file mode 100644 index 0000000..1666d58 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_nsecs_to_ticks.md @@ -0,0 +1,24 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_nsecs_to_ticks</font> + +```c +uint32_t os_cputime_nsecs_to_ticks(uint32_t nsecs) +``` +Converts a specified number of nanoseconds to cputime ticks. + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `nsecs` | Number of nanoseconds to convert to ticks. + + +#### Returned values +The number of ticks in `nsecs` nanoseconds. + +#### Notes + +#### Example +```c +uint32_t num_ticks; +num_ticks = os_cputime_nsecs_to_ticks(1000000); +``` http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_ticks_to_nsecs.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_ticks_to_nsecs.md b/docs/os/core_os/cputime/os_cputime_ticks_to_nsecs.md new file mode 100644 index 0000000..dc6afa0 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_ticks_to_nsecs.md @@ -0,0 +1,24 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_ticks_to_nsecs</font> + +```c +uint32_t os_cputime_ticks_to_nsecs(uint32_t ticks) +``` +Converts cputime ticks to nanoseconds. + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `ticks` | Number of cputime ticks to convert to nanoseconds. + + +#### Returned values +The number of nanoseconds in `ticks` number of ticks. + +#### Notes + +#### Example +```c +uint32_t num_nsecs; +num_nsecs = os_cputime_ticks_to_nsecs(1000000); +``` http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_ticks_to_usecs.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_ticks_to_usecs.md b/docs/os/core_os/cputime/os_cputime_ticks_to_usecs.md new file mode 100644 index 0000000..6fcc496 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_ticks_to_usecs.md @@ -0,0 +1,24 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_ticks_to_usecs</font> + +```c +uint32_t os_cputime_ticks_to_usecs(uint32_t ticks) +``` +Converts a specified number of cputime ticks to microseconds. + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `ticks` | Number of cputime ticks to convert to microseconds. + + +#### Returned values +The number of microseconds in `ticks` number of ticks. + +#### Notes + +#### Example +```c +uint32_t num_usecs; +num_usecs = os_cputime_ticks_to_usecs(1000000); +``` http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_timer_init.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_timer_init.md b/docs/os/core_os/cputime/os_cputime_timer_init.md new file mode 100644 index 0000000..7fba485 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_timer_init.md @@ -0,0 +1,65 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_timer_init</font> + +```c +void os_cputime_timer_init(struct hal_timer *timer, hal_timer_cb fp, void *arg) +``` +Initializes a cputime timer, indicated by `timer`, with a pointer to a callback function to call when the timer expires. When an optional opaque argument is specified, it is passed to the timer callback function. + +The callback function has the following prototype: +```c +void hal_timer_cb(void *arg) +``` + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `timer` | Pointer to the hal_timer to initialize. This value cannot be NULL. +| `fp` | Pointer to the callback function to call when the timer expires. This value cannot be NULL. +| `arg` | Optional opaque argument to pass to the hal timer callback function. + + +#### Returned values +N/A + +#### Notes + +#### Example + +Example of ble_ll setting up a response timer: + +```c +ble_ll_wfr_timer_exp(void *arg) +{ + int rx_start; + uint8_t lls; + + ... + + /* If we have started a reception, there is nothing to do here */ + if (!rx_start) { + switch (lls) { + case BLE_LL_STATE_ADV: + ble_ll_adv_wfr_timer_exp(); + break; + + ... + + /* Do nothing here. Fall through intentional */ + case BLE_LL_STATE_INITIATING: + default: + break; + } + } +} + +void ble_ll_init(void) +{ + ... + + os_cputime_timer_init(&g_ble_ll_data.ll_wfr_timer, ble_ll_wfr_timer_exp, NULL); + + ... +} +``` + http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_timer_relative.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_timer_relative.md b/docs/os/core_os/cputime/os_cputime_timer_relative.md new file mode 100644 index 0000000..2d420a8 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_timer_relative.md @@ -0,0 +1,33 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_timer_relative</font> + +```c +void os_cputime_timer_relative(struct hal_timer *timer, uint32_t usecs) +``` +Sets a timer to expire in the specified number of microseconds from the current time. The callback function for the timer is called when the timer expires. + + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `timer` | Pointer to an initialized hal_timer. +| `usecs` | The number of microseconds to set the timer to expire from now. + + +#### Returned values +N/A + +#### Notes + +`timer` must be initialized using the `os_cputime_timer_init()` function before setting up a timer. + +#### Example +` +```c +struct hal_timer mytimer; + ... + +os_cputime_timer_relative(&mytimer, 100); + +``` + http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_timer_start.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_timer_start.md b/docs/os/core_os/cputime/os_cputime_timer_start.md new file mode 100644 index 0000000..4cdba9c --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_timer_start.md @@ -0,0 +1,34 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_timer_start</font> + +```c +void os_cputime_timer_start(struct hal_timer *timer, uint32_t cputime) +``` +Sets a timer to expire at the specified cputime. The callback function for the timer is called when the timer expires. + + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `timer` | Pointer to an initialized hal_timer. +| `cputime` | The cputime when the timer expires. + + +#### Returned values +N/A + +#### Notes + +`timer` must be initialized using the `os_cputime_timer_init()` function before setting up a timer. + +#### Example + +```c +void +ble_ll_wfr_enable(uint32_t cputime) +{ + os_cputime_timer_start(&g_ble_ll_data.ll_wfr_timer, cputime); +} + +``` + http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_timer_stop.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_timer_stop.md b/docs/os/core_os/cputime/os_cputime_timer_stop.md new file mode 100644 index 0000000..5c38f06 --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_timer_stop.md @@ -0,0 +1,30 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_timer_stop</font> + +```c +void os_cputime_timer_stop(struct hal_timer *timer) +``` +Stops a timer from running. The timer is removed from the timer queue and interrupts are disabled if there are no more timers on the timer queue. + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `timer` | Pointer to the timer to stop. + + +#### Returned values +N/A + +#### Notes + +#### Example + +```c +void +ble_ll_wfr_disable(void) +{ + os_cputime_timer_stop(&g_ble_ll_data.ll_wfr_timer); +} + +``` + http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/cputime/os_cputime_usecs_to_ticks.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/cputime/os_cputime_usecs_to_ticks.md b/docs/os/core_os/cputime/os_cputime_usecs_to_ticks.md new file mode 100644 index 0000000..dd6618d --- /dev/null +++ b/docs/os/core_os/cputime/os_cputime_usecs_to_ticks.md @@ -0,0 +1,24 @@ +## <font color="F2853F" style="font-size:24pt">os_cputime_usecs_to_ticks</font> + +```c +uint32_t os_cputime_usecs_to_ticks(uint32_t usecs) +``` +Converts a specified number of microseconds to cputime ticks. + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `usecs` | Number of microseconds to convert to ticks. + + +#### Returned values +The number of ticks in `usecs` nanoseconds. + +#### Notes + +#### Example +```c +uint32_t num_ticks; +num_ticks = os_cputime_usecs_to_ticks(100); +``` http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/time/os_get_uptime_usec.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/time/os_get_uptime_usec.md b/docs/os/core_os/time/os_get_uptime_usec.md new file mode 100644 index 0000000..4859196 --- /dev/null +++ b/docs/os/core_os/time/os_get_uptime_usec.md @@ -0,0 +1,24 @@ +## <font color="F2853F" style="font-size:24pt">os_get_uptime_usec</font> + +```c +int64_t os_get_uptime_usec(void) +``` +Gets the time duration, in microseconds, since boot. + +#### Arguments + +N/A + +#### Returned values +Time since boot in microseconds. + +#### Notes + +#### Example + +<Add text to set up the context for the example here> + +```c + int64_t time_since_boot; + time_since_boot = os_get_uptime_usec(); +``` http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/time/os_time.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/time/os_time.md b/docs/os/core_os/time/os_time.md index 52d0376..44b33f7 100644 --- a/docs/os/core_os/time/os_time.md +++ b/docs/os/core_os/time/os_time.md @@ -50,11 +50,13 @@ The functions available in time are: | **Function** | **Description** | |-----------|-------------| +| [os_time_advance](os_time_advance.md) | Increments the OS time tick for the system. | | [os_time_delay](os_time_delay.md) | Put the current task to sleep for the given number of ticks. | | [os_time_get](os_time_get.md) | Get the current value of OS time. | -| [os_time_tick](os_time_tick.md) | Increments the OS time tick for the system. | -| [os_settimeofday](os_settimeofday.md) | Set the current time of day to the given time structs. | +| [os_time_ms_to_ticks](os_time_ms_to_ticks.md) | Converts milliseconds to os ticks. | +| [os_get_uptime_usec](os_get_uptime_usec.md) | Gets the time duration since boot. | | [os_gettimeofday](os_gettimeofday.md) | Populate the given timeval and timezone structs with current time data. | +| [os_settimeofday](os_settimeofday.md) | Set the current time of day to the given time structs. | ## List of Macros http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/time/os_time_advance.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/time/os_time_advance.md b/docs/os/core_os/time/os_time_advance.md new file mode 100644 index 0000000..fff1245 --- /dev/null +++ b/docs/os/core_os/time/os_time_advance.md @@ -0,0 +1,22 @@ +## <font color="F2853F" style="font-size:24pt">os_time_advance</font> + +```c +void os_time_advance(int ticks) +``` +Moves the OS time forward by the value specified in `ticks`. Typically, this is called in one place by the architecture specific OS code (kernel/os/src/arch) timer_handler which is in turn called by the BSP specific code assigned to drive the OS timer tick. See Porting Mynewt OS for details. + +#### Arguments + +| Arguments | Description | +|-----------|-------------| +| `ticks` | Number of ticks to move the OS time forward. | + + +#### Returned values + +N/A + +#### Notes + + +#### Example http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/time/os_time_ms_to_ticks.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/time/os_time_ms_to_ticks.md b/docs/os/core_os/time/os_time_ms_to_ticks.md new file mode 100644 index 0000000..4508012 --- /dev/null +++ b/docs/os/core_os/time/os_time_ms_to_ticks.md @@ -0,0 +1,29 @@ +## <font color="F2853F" style="font-size:24pt">os_time_ms_to_ticks</font> + +```c +int os_time_ms_to_ticks(uint32_t ms, uint32_t *out_ticks) +``` +Converts milliseconds to OS ticks. + +#### Arguments +| Arguments | Description | +|-----------|-------------| +| `ms` | Number of milliseconds to convert to OS ticks. | +| `out_ticks` | Pointer to an uint32_t to return the number of OS ticks for `ms` milliseconds.| + +N/A + +#### Returned values +`0`: Success +<br>`OS_EINVAL`: Number of ticks is too large to fit in an uint32_t. + +N/A + +#### Notes + + +#### Example +```c +unint32_t num_ticks; +os_time_ms_to_ticks(50, &num_ticks); +``` http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/docs/os/core_os/time/os_time_tick.md ---------------------------------------------------------------------- diff --git a/docs/os/core_os/time/os_time_tick.md b/docs/os/core_os/time/os_time_tick.md deleted file mode 100644 index 1c217e1..0000000 --- a/docs/os/core_os/time/os_time_tick.md +++ /dev/null @@ -1,27 +0,0 @@ -## <font color="F2853F" style="font-size:24pt">os_time_tick</font> - -```c -void os_time_tick(void) -``` - -Increments the OS time tick for the system. Typically, this is called in one place by the architecture specific OS code (`libs/os/arch`) `timer_handler` which is in turn called by the BSP specific code assigned to drive the OS timer tick. See [Porting Mynewt OS](../porting/port_os) for details. - -#### Arguments - -N/A - -#### Returned values - -N/A - -#### Notes - -Called for every single tick by the architecture specific functions. - -#### Example - -<Add text to set up the context for the example here> - -```c - os_time_tick(); -``` http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/be606a2e/mkdocs.yml ---------------------------------------------------------------------- diff --git a/mkdocs.yml b/mkdocs.yml index 0080930..915a1e7 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -89,12 +89,30 @@ pages: - 'os_sched_set_current_task': 'os/core_os/context_switch/os_sched_set_current_task.md' - 'os_sched_sleep': 'os/core_os/context_switch/os_sched_sleep.md' - 'os_sched_wakeup': 'os/core_os/context_switch/os_sched_wakeup.md' - - Time: + - CPU Time: + - toc: 'os/core_os/cputime/os_cputime.md' + - 'Functions': + - 'os_cputime_delay_nsecs': 'os/core_os/cputime/os_cputime_delay_nsecs.md' + - 'os_cputime_delay_ticks': 'os/core_os/cputime/os_cputime_delay_ticks.md' + - 'os_cputime_delay_usecs': 'os/core_os/cputime/os_cputime_delay_usecs.md' + - 'os_cputime_get32': 'os/core_os/cputime/os_cputime_get32.md' + - 'os_cputime_init': 'os/core_os/cputime/os_cputime_init.md' + - 'os_cputime_nsecs_to_ticks': 'os/core_os/cputime/os_cputime_nsecs_to_ticks.md' + - 'os_cputime_ticks_to_nsecs': 'os/core_os/cputime/os_cputime_ticks_to_nsecs.md' + - 'os_cputime_ticks_to_usecs': 'os/core_os/cputime/os_cputime_ticks_to_usecs.md' + - 'os_cputime_timer_init': 'os/core_os/cputime/os_cputime_timer_init.md' + - 'os_cputime_timer_relative': 'os/core_os/cputime/os_cputime_timer_relative.md' + - 'os_cputime_timer_start': 'os/core_os/cputime/os_cputime_timer_start.md' + - 'os_cputime_timer_stop': 'os/core_os/cputime/os_cputime_timer_stop.md' + - 'os_cputime_usecs_to_ticks': 'os/core_os/cputime/os_cputime_usecs_to_ticks.md' + - OS Time: - toc: 'os/core_os/time/os_time.md' - 'Functions': + - 'os_time_advance': 'os/core_os/time/os_time_advance.md' - 'os_time_delay': 'os/core_os/time/os_time_delay.md' - 'os_time_get': 'os/core_os/time/os_time_get.md' - - 'os_time_tick': 'os/core_os/time/os_time_tick.md' + - 'os_time_ms_to_ticks': 'os/core_os/time/os_time_ms_to_ticks.md' + - 'os_get_uptime_usec': 'os/core_os/time/os_get_uptime_usec.md' - 'os_gettimeofday': 'os/core_os/time/os_gettimeofday.md' - 'os_settimeofday': 'os/core_os/time/os_settimeofday.md' - Tasks:
