Rahul Dahiya / Mbed OS STM32F7 Ethernet
Committer:
rahul_dahiya
Date:
Wed Jan 15 15:57:15 2020 +0530
Revision:
0:fb8047b156bb
STM32F7 LWIP

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rahul_dahiya 0:fb8047b156bb 1 /* mbed Microcontroller Library
rahul_dahiya 0:fb8047b156bb 2 * Copyright (c) 2006-2012 ARM Limited
rahul_dahiya 0:fb8047b156bb 3 *
rahul_dahiya 0:fb8047b156bb 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
rahul_dahiya 0:fb8047b156bb 5 * of this software and associated documentation files (the "Software"), to deal
rahul_dahiya 0:fb8047b156bb 6 * in the Software without restriction, including without limitation the rights
rahul_dahiya 0:fb8047b156bb 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
rahul_dahiya 0:fb8047b156bb 8 * copies of the Software, and to permit persons to whom the Software is
rahul_dahiya 0:fb8047b156bb 9 * furnished to do so, subject to the following conditions:
rahul_dahiya 0:fb8047b156bb 10 *
rahul_dahiya 0:fb8047b156bb 11 * The above copyright notice and this permission notice shall be included in
rahul_dahiya 0:fb8047b156bb 12 * all copies or substantial portions of the Software.
rahul_dahiya 0:fb8047b156bb 13 *
rahul_dahiya 0:fb8047b156bb 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
rahul_dahiya 0:fb8047b156bb 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
rahul_dahiya 0:fb8047b156bb 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
rahul_dahiya 0:fb8047b156bb 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
rahul_dahiya 0:fb8047b156bb 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
rahul_dahiya 0:fb8047b156bb 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
rahul_dahiya 0:fb8047b156bb 20 * SOFTWARE.
rahul_dahiya 0:fb8047b156bb 21 */
rahul_dahiya 0:fb8047b156bb 22 #include "rtos/RtosTimer.h"
rahul_dahiya 0:fb8047b156bb 23
rahul_dahiya 0:fb8047b156bb 24 #include <string.h>
rahul_dahiya 0:fb8047b156bb 25
rahul_dahiya 0:fb8047b156bb 26 #include "mbed.h"
rahul_dahiya 0:fb8047b156bb 27 #include "platform/mbed_error.h"
rahul_dahiya 0:fb8047b156bb 28
rahul_dahiya 0:fb8047b156bb 29 namespace rtos {
rahul_dahiya 0:fb8047b156bb 30
rahul_dahiya 0:fb8047b156bb 31 void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
rahul_dahiya 0:fb8047b156bb 32 _function = func;
rahul_dahiya 0:fb8047b156bb 33 memset(&_obj_mem, 0, sizeof(_obj_mem));
rahul_dahiya 0:fb8047b156bb 34 osTimerAttr_t attr = { 0 };
rahul_dahiya 0:fb8047b156bb 35 attr.cb_mem = &_obj_mem;
rahul_dahiya 0:fb8047b156bb 36 attr.cb_size = sizeof(_obj_mem);
rahul_dahiya 0:fb8047b156bb 37 _id = osTimerNew((void (*)(void *))Callback<void()>::thunk, type, &_function, &attr);
rahul_dahiya 0:fb8047b156bb 38 MBED_ASSERT(_id);
rahul_dahiya 0:fb8047b156bb 39 }
rahul_dahiya 0:fb8047b156bb 40
rahul_dahiya 0:fb8047b156bb 41 osStatus RtosTimer::start(uint32_t millisec) {
rahul_dahiya 0:fb8047b156bb 42 return osTimerStart(_id, millisec);
rahul_dahiya 0:fb8047b156bb 43 }
rahul_dahiya 0:fb8047b156bb 44
rahul_dahiya 0:fb8047b156bb 45 osStatus RtosTimer::stop(void) {
rahul_dahiya 0:fb8047b156bb 46 return osTimerStop(_id);
rahul_dahiya 0:fb8047b156bb 47 }
rahul_dahiya 0:fb8047b156bb 48
rahul_dahiya 0:fb8047b156bb 49 RtosTimer::~RtosTimer() {
rahul_dahiya 0:fb8047b156bb 50 osTimerDelete(_id);
rahul_dahiya 0:fb8047b156bb 51 }
rahul_dahiya 0:fb8047b156bb 52
rahul_dahiya 0:fb8047b156bb 53 }