mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Fri Jul 17 09:15:10 2015 +0100
Revision:
592:a274ee790e56
Parent:
579:53297373a894
Synchronized with git revision e7144f83a8d75df80c4877936b6ffe552b0be9e6

Full URL: https://github.com/mbedmicro/mbed/commit/e7144f83a8d75df80c4877936b6ffe552b0be9e6/

More API implementation for SAMR21

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 579:53297373a894 1 #ifndef CYCLE_COUNTER_H_INCLUDED
mbed_official 579:53297373a894 2 #define CYCLE_COUNTER_H_INCLUDED
mbed_official 579:53297373a894 3
mbed_official 579:53297373a894 4 #include <compiler.h>
mbed_official 579:53297373a894 5 #include <clock.h>
mbed_official 579:53297373a894 6
mbed_official 579:53297373a894 7 #ifdef __cplusplus
mbed_official 579:53297373a894 8 extern "C" {
mbed_official 579:53297373a894 9 #endif
mbed_official 579:53297373a894 10
mbed_official 579:53297373a894 11 /**
mbed_official 579:53297373a894 12 * \name Convenience functions for busy-wait delay loops
mbed_official 579:53297373a894 13 *
mbed_official 579:53297373a894 14 * @{
mbed_official 579:53297373a894 15 */
mbed_official 579:53297373a894 16
mbed_official 579:53297373a894 17 /**
mbed_official 579:53297373a894 18 * \brief Delay loop to delay n number of cycles
mbed_official 579:53297373a894 19 * Delay program execution for at least the specified number of CPU cycles.
mbed_official 579:53297373a894 20 *
mbed_official 579:53297373a894 21 * \param n Number of cycles to delay
mbed_official 579:53297373a894 22 */
mbed_official 579:53297373a894 23 static inline void delay_cycles(
mbed_official 579:53297373a894 24 const uint32_t n)
mbed_official 579:53297373a894 25 {
mbed_official 579:53297373a894 26 if (n > 0) {
mbed_official 579:53297373a894 27 SysTick->LOAD = n;
mbed_official 579:53297373a894 28 SysTick->VAL = 0;
mbed_official 579:53297373a894 29
mbed_official 579:53297373a894 30 while (!(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)) {
mbed_official 579:53297373a894 31 };
mbed_official 579:53297373a894 32 }
mbed_official 579:53297373a894 33 }
mbed_official 579:53297373a894 34
mbed_official 579:53297373a894 35 void delay_cycles_us(uint32_t n);
mbed_official 579:53297373a894 36
mbed_official 579:53297373a894 37 void delay_cycles_ms(uint32_t n);
mbed_official 579:53297373a894 38
mbed_official 579:53297373a894 39 /**
mbed_official 579:53297373a894 40 * \brief Delay program execution for at least the specified number of microseconds.
mbed_official 579:53297373a894 41 *
mbed_official 579:53297373a894 42 * \param delay number of microseconds to wait
mbed_official 579:53297373a894 43 */
mbed_official 579:53297373a894 44 #define cpu_delay_us(delay) delay_cycles_us(delay)
mbed_official 579:53297373a894 45
mbed_official 579:53297373a894 46 /**
mbed_official 579:53297373a894 47 * \brief Delay program execution for at least the specified number of milliseconds.
mbed_official 579:53297373a894 48 *
mbed_official 579:53297373a894 49 * \param delay number of milliseconds to wait
mbed_official 579:53297373a894 50 */
mbed_official 579:53297373a894 51 #define cpu_delay_ms(delay) delay_cycles_ms(delay)
mbed_official 579:53297373a894 52
mbed_official 579:53297373a894 53 /**
mbed_official 579:53297373a894 54 * \brief Delay program execution for at least the specified number of seconds.
mbed_official 579:53297373a894 55 *
mbed_official 579:53297373a894 56 * \param delay number of seconds to wait
mbed_official 579:53297373a894 57 */
mbed_official 579:53297373a894 58 #define cpu_delay_s(delay) delay_cycles_ms(1000 * delay)
mbed_official 579:53297373a894 59
mbed_official 579:53297373a894 60 /**
mbed_official 579:53297373a894 61 * @}
mbed_official 579:53297373a894 62 */
mbed_official 579:53297373a894 63
mbed_official 579:53297373a894 64 #ifdef __cplusplus
mbed_official 579:53297373a894 65 }
mbed_official 579:53297373a894 66 #endif
mbed_official 579:53297373a894 67
mbed_official 579:53297373a894 68 #endif /* CYCLE_COUNTER_H_INCLUDED */