cc y / mbed

Fork of mbed by mbed official

Committer:
AnnaBridge
Date:
Wed Aug 31 18:09:46 2016 +0100
Revision:
125:2e9cc70d1897
Parent:
122:f9eeca106725
Release 125 of the mbed library

Changes:

New target - KL27Z_IAR
New target - MAX32620HSP_ARM_STD
New target - MAX32620HSP_GCC_ARM
New target - MAX32620HSP_IAR
New target - NCS36510_ARM_STD
New target - NCS36510_GCC_ARM
New target - NCS36510_IAR

Added support for NSAPI_REUSEADDR to the lwip interface.
STM32F3 family : Add and enable asynchronous serial, plus tests.
STM32L4 family : Add and enable asynchronous serial, plus tests.
Fixing issue where GCC fails to report compile errors when non-verbose.
Add ethernet and IPV4 support for: NUCLEO_F207ZG, NUCLEO_F429ZI, NUCLEO_F767ZI, DISCO_F746NG.
RZ_A1H - Enable SPI1 on pins P6_4 to P6_7.
KL27Z : SPI driver bug fixes and Improvements, ARM linker file update.
STM32F4, STM32F7 families : Add entropy functions, documentation, code improvements, fix build issues.
HEXIWEAR: Update I2C pin mapping, Add support to create KDS projects.
LWIP - fix recv blocking send on accepted sockets.
SingletonPtr bugfixes.
Beetle: Implement sleep API.
uVisor: Update to v0.20.1-alpha, minor documentation update.
STM32F3 : fix RTOS IAR test, RTOS GCC_ARM test.
nrf5x : Introduce uart hardware flow control configuration.
K64F/K22F: Implement HAL lp_timer API.
Ticker: Move ticker initialisation to object creation time.
STM32F4 : remove printf from pwmout
NXP : Fix multiple definition errors in GCC_CR build, fix linker errors.
Add TOOLCHAIN_GCC_CR support.
STM32L1 family : Add and enable asynchronous serial, plus tests.
mbed-client : Fix Bootstrap and Connector functionality.
NUC472 : Fix Ethernet wrong INT status in RX_Action.
RTX_CM_lib.h : fix compiler warning.
NUCLEO : Use GCC small build for 64K flash STM32.
STM32F2 family : Add and enable asynchronous serial, plus tests.
uvisor : Move page heap after uVisor private data, update page allocator.
K64F: Revert to hardcoded stack pointer in RTX .
dns-query : Internal API change , documentation, Added support for multiple results and ipv6.
Add support for implementation-provided DNS servers.
Adopted netconn_gethostbyname in the lwip interface.
Restructured nsapi_dns.h to have clear separation between C/C++ .
Tool fixes.
Tests : New ones added and some updates to existing.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 65:5798e58a58b1 1 /* mbed Microcontroller Library
bogdanm 65:5798e58a58b1 2 * Copyright (c) 2006-2013 ARM Limited
bogdanm 65:5798e58a58b1 3 *
bogdanm 65:5798e58a58b1 4 * Licensed under the Apache License, Version 2.0 (the "License");
bogdanm 65:5798e58a58b1 5 * you may not use this file except in compliance with the License.
bogdanm 65:5798e58a58b1 6 * You may obtain a copy of the License at
bogdanm 65:5798e58a58b1 7 *
bogdanm 65:5798e58a58b1 8 * http://www.apache.org/licenses/LICENSE-2.0
bogdanm 65:5798e58a58b1 9 *
bogdanm 65:5798e58a58b1 10 * Unless required by applicable law or agreed to in writing, software
bogdanm 65:5798e58a58b1 11 * distributed under the License is distributed on an "AS IS" BASIS,
bogdanm 65:5798e58a58b1 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bogdanm 65:5798e58a58b1 13 * See the License for the specific language governing permissions and
bogdanm 65:5798e58a58b1 14 * limitations under the License.
bogdanm 65:5798e58a58b1 15 */
bogdanm 65:5798e58a58b1 16 #ifndef MBED_TICKER_H
bogdanm 65:5798e58a58b1 17 #define MBED_TICKER_H
bogdanm 65:5798e58a58b1 18
bogdanm 65:5798e58a58b1 19 #include "TimerEvent.h"
Kojto 122:f9eeca106725 20 #include "Callback.h"
bogdanm 65:5798e58a58b1 21
bogdanm 65:5798e58a58b1 22 namespace mbed {
bogdanm 65:5798e58a58b1 23
bogdanm 65:5798e58a58b1 24 /** A Ticker is used to call a function at a recurring interval
bogdanm 65:5798e58a58b1 25 *
bogdanm 65:5798e58a58b1 26 * You can use as many seperate Ticker objects as you require.
bogdanm 65:5798e58a58b1 27 *
Kojto 122:f9eeca106725 28 * @Note Synchronization level: Interrupt safe
Kojto 122:f9eeca106725 29 *
bogdanm 65:5798e58a58b1 30 * Example:
bogdanm 65:5798e58a58b1 31 * @code
bogdanm 65:5798e58a58b1 32 * // Toggle the blinking led after 5 seconds
bogdanm 65:5798e58a58b1 33 *
bogdanm 65:5798e58a58b1 34 * #include "mbed.h"
bogdanm 65:5798e58a58b1 35 *
bogdanm 65:5798e58a58b1 36 * Ticker timer;
bogdanm 65:5798e58a58b1 37 * DigitalOut led1(LED1);
bogdanm 65:5798e58a58b1 38 * DigitalOut led2(LED2);
bogdanm 65:5798e58a58b1 39 *
bogdanm 65:5798e58a58b1 40 * int flip = 0;
bogdanm 65:5798e58a58b1 41 *
bogdanm 65:5798e58a58b1 42 * void attime() {
bogdanm 65:5798e58a58b1 43 * flip = !flip;
bogdanm 65:5798e58a58b1 44 * }
bogdanm 65:5798e58a58b1 45 *
bogdanm 65:5798e58a58b1 46 * int main() {
bogdanm 65:5798e58a58b1 47 * timer.attach(&attime, 5);
bogdanm 65:5798e58a58b1 48 * while(1) {
bogdanm 65:5798e58a58b1 49 * if(flip == 0) {
bogdanm 65:5798e58a58b1 50 * led1 = !led1;
bogdanm 65:5798e58a58b1 51 * } else {
bogdanm 65:5798e58a58b1 52 * led2 = !led2;
bogdanm 65:5798e58a58b1 53 * }
bogdanm 65:5798e58a58b1 54 * wait(0.2);
bogdanm 65:5798e58a58b1 55 * }
bogdanm 65:5798e58a58b1 56 * }
bogdanm 65:5798e58a58b1 57 * @endcode
bogdanm 65:5798e58a58b1 58 */
bogdanm 65:5798e58a58b1 59 class Ticker : public TimerEvent {
bogdanm 65:5798e58a58b1 60
bogdanm 65:5798e58a58b1 61 public:
Kojto 98:8ab26030e058 62 Ticker() : TimerEvent() {
Kojto 98:8ab26030e058 63 }
Kojto 98:8ab26030e058 64
Kojto 100:cbbeb26dbd92 65 Ticker(const ticker_data_t *data) : TimerEvent(data) {
AnnaBridge 125:2e9cc70d1897 66 data->interface->init();
Kojto 98:8ab26030e058 67 }
bogdanm 65:5798e58a58b1 68
bogdanm 65:5798e58a58b1 69 /** Attach a function to be called by the Ticker, specifiying the interval in seconds
bogdanm 65:5798e58a58b1 70 *
Kojto 122:f9eeca106725 71 * @param func pointer to the function to be called
bogdanm 65:5798e58a58b1 72 * @param t the time between calls in seconds
bogdanm 65:5798e58a58b1 73 */
Kojto 122:f9eeca106725 74 void attach(Callback<void()> func, float t) {
Kojto 122:f9eeca106725 75 attach_us(func, t * 1000000.0f);
bogdanm 65:5798e58a58b1 76 }
bogdanm 65:5798e58a58b1 77
bogdanm 65:5798e58a58b1 78 /** Attach a member function to be called by the Ticker, specifiying the interval in seconds
bogdanm 65:5798e58a58b1 79 *
Kojto 122:f9eeca106725 80 * @param obj pointer to the object to call the member function on
Kojto 122:f9eeca106725 81 * @param method pointer to the member function to be called
bogdanm 65:5798e58a58b1 82 * @param t the time between calls in seconds
bogdanm 65:5798e58a58b1 83 */
Kojto 122:f9eeca106725 84 template<typename T, typename M>
Kojto 122:f9eeca106725 85 void attach(T *obj, M method, float t) {
Kojto 122:f9eeca106725 86 attach(Callback<void()>(obj, method), t);
bogdanm 65:5798e58a58b1 87 }
bogdanm 65:5798e58a58b1 88
bogdanm 65:5798e58a58b1 89 /** Attach a function to be called by the Ticker, specifiying the interval in micro-seconds
bogdanm 65:5798e58a58b1 90 *
bogdanm 65:5798e58a58b1 91 * @param fptr pointer to the function to be called
bogdanm 65:5798e58a58b1 92 * @param t the time between calls in micro-seconds
bogdanm 65:5798e58a58b1 93 */
Kojto 122:f9eeca106725 94 void attach_us(Callback<void()> func, timestamp_t t) {
Kojto 122:f9eeca106725 95 _function.attach(func);
bogdanm 65:5798e58a58b1 96 setup(t);
bogdanm 65:5798e58a58b1 97 }
bogdanm 65:5798e58a58b1 98
bogdanm 65:5798e58a58b1 99 /** Attach a member function to be called by the Ticker, specifiying the interval in micro-seconds
bogdanm 65:5798e58a58b1 100 *
bogdanm 65:5798e58a58b1 101 * @param tptr pointer to the object to call the member function on
bogdanm 65:5798e58a58b1 102 * @param mptr pointer to the member function to be called
bogdanm 65:5798e58a58b1 103 * @param t the time between calls in micro-seconds
bogdanm 65:5798e58a58b1 104 */
Kojto 122:f9eeca106725 105 template<typename T, typename M>
Kojto 122:f9eeca106725 106 void attach_us(T *obj, M method, timestamp_t t) {
Kojto 122:f9eeca106725 107 attach_us(Callback<void()>(obj, method), t);
bogdanm 65:5798e58a58b1 108 }
bogdanm 65:5798e58a58b1 109
bogdanm 89:552587b429a1 110 virtual ~Ticker() {
bogdanm 89:552587b429a1 111 detach();
bogdanm 89:552587b429a1 112 }
bogdanm 89:552587b429a1 113
bogdanm 65:5798e58a58b1 114 /** Detach the function
bogdanm 65:5798e58a58b1 115 */
bogdanm 65:5798e58a58b1 116 void detach();
bogdanm 65:5798e58a58b1 117
bogdanm 65:5798e58a58b1 118 protected:
bogdanm 89:552587b429a1 119 void setup(timestamp_t t);
bogdanm 65:5798e58a58b1 120 virtual void handler();
bogdanm 65:5798e58a58b1 121
bogdanm 89:552587b429a1 122 protected:
Kojto 122:f9eeca106725 123 timestamp_t _delay; /**< Time delay (in microseconds) for re-setting the multi-shot callback. */
Kojto 122:f9eeca106725 124 Callback<void()> _function; /**< Callback. */
bogdanm 65:5798e58a58b1 125 };
bogdanm 65:5798e58a58b1 126
bogdanm 65:5798e58a58b1 127 } // namespace mbed
bogdanm 65:5798e58a58b1 128
bogdanm 65:5798e58a58b1 129 #endif