mbed
Fork of mbed-dev by
Revision 145:ce498f071de9, committed 2016-09-07
- Comitter:
- sam_grove
- Date:
- Wed Sep 07 20:44:12 2016 +0000
- Parent:
- 144:ef7eb2e8f9f7
- Child:
- 146:11f9a9a04805
- Commit message:
- Remove duplicate files that were renamed.
Changed in this revision
--- a/common/assert.c Fri Sep 02 15:07:44 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "mbed_assert.h" -#include "mbed_error.h" - -void mbed_assert_internal(const char *expr, const char *file, int line) -{ - error("mbed assertation failed: %s, file: %s, line %d \n", expr, file, line); -}
--- a/common/board.c Fri Sep 02 15:07:44 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "gpio_api.h" -#include "wait_api.h" -#include "toolchain.h" -#include "mbed_interface.h" - -WEAK void mbed_die(void) { -#if !defined (NRF51_H) && !defined(TARGET_EFM32) - __disable_irq(); // dont allow interrupts to disturb the flash pattern -#endif -#if (DEVICE_ERROR_RED == 1) - gpio_t led_red; gpio_init_out(&led_red, LED_RED); -#elif (DEVICE_ERROR_PATTERN == 1) - gpio_t led_1; gpio_init_out(&led_1, LED1); - gpio_t led_2; gpio_init_out(&led_2, LED2); - gpio_t led_3; gpio_init_out(&led_3, LED3); - gpio_t led_4; gpio_init_out(&led_4, LED4); -#endif - - while (1) { -#if (DEVICE_ERROR_RED == 1) - gpio_write(&led_red, 1); - -#elif (DEVICE_ERROR_PATTERN == 1) - gpio_write(&led_1, 1); - gpio_write(&led_2, 0); - gpio_write(&led_3, 0); - gpio_write(&led_4, 1); -#endif - - wait_ms(150); - -#if (DEVICE_ERROR_RED == 1) - gpio_write(&led_red, 0); - -#elif (DEVICE_ERROR_PATTERN == 1) - gpio_write(&led_1, 0); - gpio_write(&led_2, 1); - gpio_write(&led_3, 1); - gpio_write(&led_4, 0); -#endif - - wait_ms(150); - } -}
--- a/common/error.c Fri Sep 02 15:07:44 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include <stdlib.h> -#include <stdarg.h> -#include "device.h" -#include "toolchain.h" -#include "mbed_error.h" -#if DEVICE_STDIO_MESSAGES -#include <stdio.h> -#endif - -WEAK void error(const char* format, ...) { -#if DEVICE_STDIO_MESSAGES - va_list arg; - va_start(arg, format); - vfprintf(stderr, format, arg); - va_end(arg); -#endif - exit(1); -}
--- a/common/gpio.c Fri Sep 02 15:07:44 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "gpio_api.h" - -static inline void _gpio_init_in(gpio_t* gpio, PinName pin, PinMode mode) -{ - gpio_init(gpio, pin); - if (pin != NC) { - gpio_dir(gpio, PIN_INPUT); - gpio_mode(gpio, mode); - } -} - -static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value) -{ - gpio_init(gpio, pin); - if (pin != NC) { - gpio_write(gpio, value); - gpio_dir(gpio, PIN_OUTPUT); - gpio_mode(gpio, mode); - } -} - -void gpio_init_in(gpio_t* gpio, PinName pin) { - gpio_init_in_ex(gpio, pin, PullDefault); -} - -void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode) { - _gpio_init_in(gpio, pin, mode); -} - -void gpio_init_out(gpio_t* gpio, PinName pin) { - gpio_init_out_ex(gpio, pin, 0); -} - -void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value) { - _gpio_init_out(gpio, pin, PullNone, value); -} - -void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value) { - if (direction == PIN_INPUT) { - _gpio_init_in(gpio, pin, mode); - if (pin != NC) - gpio_write(gpio, value); // we prepare the value in case it is switched later - } else { - _gpio_init_out(gpio, pin, mode, value); - } -}
--- a/common/lp_ticker_api.c Fri Sep 02 15:07:44 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2015 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "lp_ticker_api.h" - -#if DEVICE_LOWPOWERTIMER - -static ticker_event_queue_t events; - -static const ticker_interface_t lp_interface = { - .init = lp_ticker_init, - .read = lp_ticker_read, - .disable_interrupt = lp_ticker_disable_interrupt, - .clear_interrupt = lp_ticker_clear_interrupt, - .set_interrupt = lp_ticker_set_interrupt, -}; - -static const ticker_data_t lp_data = { - .interface = &lp_interface, - .queue = &events, -}; - -const ticker_data_t* get_lp_ticker_data(void) -{ - return &lp_data; -} - -void lp_ticker_irq_handler(void) -{ - ticker_irq_handler(&lp_data); -} - -#endif
--- a/common/pinmap_common.c Fri Sep 02 15:07:44 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "pinmap.h" -#include "mbed_error.h" - -void pinmap_pinout(PinName pin, const PinMap *map) { - if (pin == NC) - return; - - while (map->pin != NC) { - if (map->pin == pin) { - pin_function(pin, map->function); - - pin_mode(pin, PullNone); - return; - } - map++; - } - error("could not pinout"); -} - -uint32_t pinmap_merge(uint32_t a, uint32_t b) { - // both are the same (inc both NC) - if (a == b) - return a; - - // one (or both) is not connected - if (a == (uint32_t)NC) - return b; - if (b == (uint32_t)NC) - return a; - - // mis-match error case - error("pinmap mis-match"); - return (uint32_t)NC; -} - -uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) { - while (map->pin != NC) { - if (map->pin == pin) - return map->peripheral; - map++; - } - return (uint32_t)NC; -} - -uint32_t pinmap_peripheral(PinName pin, const PinMap* map) { - uint32_t peripheral = (uint32_t)NC; - - if (pin == (PinName)NC) - return (uint32_t)NC; - peripheral = pinmap_find_peripheral(pin, map); - if ((uint32_t)NC == peripheral) // no mapping available - error("pinmap not found for peripheral"); - return peripheral; -} - -uint32_t pinmap_find_function(PinName pin, const PinMap* map) { - while (map->pin != NC) { - if (map->pin == pin) - return map->function; - map++; - } - return (uint32_t)NC; -} - -uint32_t pinmap_function(PinName pin, const PinMap* map) { - uint32_t function = (uint32_t)NC; - - if (pin == (PinName)NC) - return (uint32_t)NC; - function = pinmap_find_function(pin, map); - if ((uint32_t)NC == function) // no mapping available - error("pinmap not found for function"); - return function; -}
--- a/common/rtc_time.c Fri Sep 02 15:07:44 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "rtc_api.h" - -#include <time.h> -#include "rtc_time.h" -#include "us_ticker_api.h" - -#if DEVICE_RTC -static void (*_rtc_init)(void) = rtc_init; -static int (*_rtc_isenabled)(void) = rtc_isenabled; -static time_t (*_rtc_read)(void) = rtc_read; -static void (*_rtc_write)(time_t t) = rtc_write; -#else -static void (*_rtc_init)(void) = NULL; -static int (*_rtc_isenabled)(void) = NULL; -static time_t (*_rtc_read)(void) = NULL; -static void (*_rtc_write)(time_t t) = NULL; -#endif - -#ifdef __cplusplus -extern "C" { -#endif -#if defined (__ICCARM__) -time_t __time32(time_t *timer) -#else -time_t time(time_t *timer) -#endif - -{ - if (_rtc_isenabled != NULL) { - if (!(_rtc_isenabled())) { - set_time(0); - } - } - - time_t t = 0; - if (_rtc_read != NULL) { - t = _rtc_read(); - } - - if (timer != NULL) { - *timer = t; - } - return t; -} - -void set_time(time_t t) { - if (_rtc_init != NULL) { - _rtc_init(); - } - if (_rtc_write != NULL) { - _rtc_write(t); - } -} - -clock_t clock() { - clock_t t = us_ticker_read(); - t /= 1000000 / CLOCKS_PER_SEC; // convert to processor time - return t; -} - -void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void)) { - __disable_irq(); - _rtc_read = read_rtc; - _rtc_write = write_rtc; - _rtc_init = init_rtc; - _rtc_isenabled = isenabled_rtc; - __enable_irq(); -} - - - -#ifdef __cplusplus -} -#endif
--- a/common/semihost_api.c Fri Sep 02 15:07:44 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "cmsis.h" -#include "semihost_api.h" - -#include <stdint.h> -#include <string.h> - -#if DEVICE_SEMIHOST - -// ARM Semihosting Commands -#define SYS_OPEN (0x1) -#define SYS_CLOSE (0x2) -#define SYS_WRITE (0x5) -#define SYS_READ (0x6) -#define SYS_ISTTY (0x9) -#define SYS_SEEK (0xa) -#define SYS_ENSURE (0xb) -#define SYS_FLEN (0xc) -#define SYS_REMOVE (0xe) -#define SYS_RENAME (0xf) -#define SYS_EXIT (0x18) - -// mbed Semihosting Commands -#define RESERVED_FOR_USER_APPLICATIONS (0x100) // 0x100 - 0x1ff -#define USR_XFFIND (RESERVED_FOR_USER_APPLICATIONS + 0) -#define USR_UID (RESERVED_FOR_USER_APPLICATIONS + 1) -#define USR_RESET (RESERVED_FOR_USER_APPLICATIONS + 2) -#define USR_VBUS (RESERVED_FOR_USER_APPLICATIONS + 3) -#define USR_POWERDOWN (RESERVED_FOR_USER_APPLICATIONS + 4) -#define USR_DISABLEDEBUG (RESERVED_FOR_USER_APPLICATIONS + 5) - -#if DEVICE_LOCALFILESYSTEM -FILEHANDLE semihost_open(const char* name, int openmode) { - uint32_t args[3]; - args[0] = (uint32_t)name; - args[1] = (uint32_t)openmode; - args[2] = (uint32_t)strlen(name); - return __semihost(SYS_OPEN, args); -} - -int semihost_close(FILEHANDLE fh) { - return __semihost(SYS_CLOSE, &fh); -} - -int semihost_write(FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode) { - if (length == 0) return 0; - - uint32_t args[3]; - args[0] = (uint32_t)fh; - args[1] = (uint32_t)buffer; - args[2] = (uint32_t)length; - return __semihost(SYS_WRITE, args); -} - -int semihost_read(FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode) { - uint32_t args[3]; - args[0] = (uint32_t)fh; - args[1] = (uint32_t)buffer; - args[2] = (uint32_t)length; - return __semihost(SYS_READ, args); -} - -int semihost_istty(FILEHANDLE fh) { - return __semihost(SYS_ISTTY, &fh); -} - -int semihost_seek(FILEHANDLE fh, long position) { - uint32_t args[2]; - args[0] = (uint32_t)fh; - args[1] = (uint32_t)position; - return __semihost(SYS_SEEK, args); -} - -int semihost_ensure(FILEHANDLE fh) { - return __semihost(SYS_ENSURE, &fh); -} - -long semihost_flen(FILEHANDLE fh) { - return __semihost(SYS_FLEN, &fh); -} - -int semihost_remove(const char *name) { - uint32_t args[2]; - args[0] = (uint32_t)name; - args[1] = (uint32_t)strlen(name); - return __semihost(SYS_REMOVE, args); -} - -int semihost_rename(const char *old_name, const char *new_name) { - uint32_t args[4]; - args[0] = (uint32_t)old_name; - args[1] = (uint32_t)strlen(old_name); - args[0] = (uint32_t)new_name; - args[1] = (uint32_t)strlen(new_name); - return __semihost(SYS_RENAME, args); -} -#endif - -int semihost_exit(void) { - uint32_t args[4]; - return __semihost(SYS_EXIT, args); -} - -int semihost_uid(char *uid) { - uint32_t args[2]; - args[0] = (uint32_t)uid; - args[1] = DEVICE_ID_LENGTH + 1; - return __semihost(USR_UID, &args); -} - -int semihost_reset(void) { - // Does not normally return, however if used with older firmware versions - // that do not support this call it will return -1. - return __semihost(USR_RESET, NULL); -} - -int semihost_vbus(void) { - return __semihost(USR_VBUS, NULL); -} - -int semihost_powerdown(void) { - return __semihost(USR_POWERDOWN, NULL); -} - -#if DEVICE_DEBUG_AWARENESS - -int semihost_connected(void) { - return (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) ? 1 : 0; -} - -#else -// These processors cannot know if the interface is connect, assume so: -static int is_debugger_attached = 1; - -int semihost_connected(void) { - return is_debugger_attached; -} -#endif - -int semihost_disabledebug(void) { -#if !(DEVICE_DEBUG_AWARENESS) - is_debugger_attached = 0; -#endif - return __semihost(USR_DISABLEDEBUG, NULL); -} - -#endif -
--- a/common/ticker_api.c Fri Sep 02 15:07:44 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2015 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include <stddef.h> -#include "ticker_api.h" -#include "cmsis.h" - -void ticker_set_handler(const ticker_data_t *const data, ticker_event_handler handler) { - data->interface->init(); - - data->queue->event_handler = handler; -} - -void ticker_irq_handler(const ticker_data_t *const data) { - data->interface->clear_interrupt(); - - /* Go through all the pending TimerEvents */ - while (1) { - if (data->queue->head == NULL) { - // There are no more TimerEvents left, so disable matches. - data->interface->disable_interrupt(); - return; - } - - if ((int)(data->queue->head->timestamp - data->interface->read()) <= 0) { - // This event was in the past: - // point to the following one and execute its handler - ticker_event_t *p = data->queue->head; - data->queue->head = data->queue->head->next; - if (data->queue->event_handler != NULL) { - (*data->queue->event_handler)(p->id); // NOTE: the handler can set new events - } - /* Note: We continue back to examining the head because calling the - * event handler may have altered the chain of pending events. */ - } else { - // This event and the following ones in the list are in the future: - // set it as next interrupt and return - data->interface->set_interrupt(data->queue->head->timestamp); - return; - } - } -} - -void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, timestamp_t timestamp, uint32_t id) { - /* disable interrupts for the duration of the function */ - __disable_irq(); - - // initialise our data - obj->timestamp = timestamp; - obj->id = id; - - /* Go through the list until we either reach the end, or find - an element this should come before (which is possibly the - head). */ - ticker_event_t *prev = NULL, *p = data->queue->head; - while (p != NULL) { - /* check if we come before p */ - if ((int)(timestamp - p->timestamp) < 0) { - break; - } - /* go to the next element */ - prev = p; - p = p->next; - } - /* if prev is NULL we're at the head */ - if (prev == NULL) { - data->queue->head = obj; - data->interface->set_interrupt(timestamp); - } else { - prev->next = obj; - } - /* if we're at the end p will be NULL, which is correct */ - obj->next = p; - - __enable_irq(); -} - -void ticker_remove_event(const ticker_data_t *const data, ticker_event_t *obj) { - __disable_irq(); - - // remove this object from the list - if (data->queue->head == obj) { - // first in the list, so just drop me - data->queue->head = obj->next; - if (data->queue->head == NULL) { - data->interface->disable_interrupt(); - } else { - data->interface->set_interrupt(data->queue->head->timestamp); - } - } else { - // find the object before me, then drop me - ticker_event_t* p = data->queue->head; - while (p != NULL) { - if (p->next == obj) { - p->next = obj->next; - break; - } - p = p->next; - } - } - - __enable_irq(); -} - -timestamp_t ticker_read(const ticker_data_t *const data) -{ - return data->interface->read(); -} - -int ticker_get_next_timestamp(const ticker_data_t *const data, timestamp_t *timestamp) -{ - int ret = 0; - - /* if head is NULL, there are no pending events */ - __disable_irq(); - if (data->queue->head != NULL) { - *timestamp = data->queue->head->timestamp; - ret = 1; - } - __enable_irq(); - - return ret; -}
--- a/common/us_ticker_api.c Fri Sep 02 15:07:44 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2015 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "us_ticker_api.h" - -static ticker_event_queue_t events; - -static const ticker_interface_t us_interface = { - .init = us_ticker_init, - .read = us_ticker_read, - .disable_interrupt = us_ticker_disable_interrupt, - .clear_interrupt = us_ticker_clear_interrupt, - .set_interrupt = us_ticker_set_interrupt, -}; - -static const ticker_data_t us_data = { - .interface = &us_interface, - .queue = &events, -}; - -const ticker_data_t* get_us_ticker_data(void) -{ - return &us_data; -} - -void us_ticker_irq_handler(void) -{ - ticker_irq_handler(&us_data); -}
--- a/common/wait_api.c Fri Sep 02 15:07:44 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "wait_api.h" -#include "us_ticker_api.h" - -void wait(float s) { - wait_us(s * 1000000.0f); -} - -void wait_ms(int ms) { - wait_us(ms * 1000); -} - -void wait_us(int us) { - uint32_t start = us_ticker_read(); - while ((us_ticker_read() - start) < (uint32_t)us); -}