![](/media/cache/profiles/ce7206100d5cf8e7bb691376c7d73526.jpg.50x50_q85.jpg)
An example project for the Heltec Turtle LoRa board (STM32L4 and SX1276 chips). The projects is only supported for the Nucleo-L432KC board platform in the mbed online and offline compiler environment. Visit www.radioshuttle.de (choose Turtle board) for instructions. Note that most source files and libraries are open source, however some files especially the RadioShuttle core protocol is copyrighted work. Check header for details.
Dependencies: mbed BufferedSerial SX1276GenericLib OLED_SSD1306 HELIOS_Si7021 NVProperty RadioShuttle-STM32L4 USBDeviceHT
Utils/arch.cpp
- Committer:
- Helmut Tschemernjak
- Date:
- 2019-06-06
- Revision:
- 62:86aaaf9fa55d
- Parent:
- 43:ec1b7aa823a6
File content as of revision 62:86aaaf9fa55d:
/* * $Id: $ * This is an unpublished work copyright (c) 2019 HELIOS Software GmbH * 30827 Garbsen, Germany */ #include <mbed.h> #include "arch.h" // -------------------------------------------------------------------------------------------------------------------- #ifndef TOOLCHAIN_GCC _extern_c size_t strnlen(const char *s, size_t maxlen) { const char *endp = static_cast<const char *>(memchr(s, 0, maxlen)); if (endp == NULL) { return maxlen; } else { return endp - s; } } _extern_c char *strdup(const char *s) { size_t sz = strlen(s) + 1; char *news = static_cast<char *>(malloc(sz)); if (news) { memcpy(news, s, sz); } return news; } // _extern_c char *stpcpy(char *dest, const char *src) { // size_t l = strlen(src); // memcpy(dest, src, l+1); // return dest + l; // } #endif // -------------------------------------------------------------------------------------------------------------------- #ifdef TARGET_STM32L0 #ifdef TOOLCHAIN_GCC _extern_c unsigned int __atomic_fetch_or_4(volatile void *mem, unsigned int val, int model) { volatile unsigned int *ptr = static_cast<volatile unsigned int *>(mem); core_util_critical_section_enter(); unsigned int tmp = *ptr; *ptr = tmp | val; core_util_critical_section_exit(); return tmp; } _extern_c unsigned int __atomic_exchange_4(volatile void *mem, unsigned int val, int model) { volatile unsigned int *ptr = static_cast<volatile unsigned int *>(mem); core_util_critical_section_enter(); unsigned int tmp = *ptr; *ptr = val; core_util_critical_section_exit(); return tmp; } #else _extern_c bool __user_cmpxchg_1(unsigned char *ptr, unsigned char oldp, unsigned char newp) { return !core_util_atomic_cas_u8(ptr, &oldp, newp); // core_util_critical_section_enter(); // bool r = (*ptr == oldp); // if (r) { // *ptr = newp; // } // core_util_critical_section_exit(); // return !r; } _extern_c bool __user_cmpxchg_4(unsigned int *ptr, unsigned int oldp, unsigned int newp) { return !core_util_atomic_cas_u32(ptr, &oldp, newp); // core_util_critical_section_enter(); // bool r = (*ptr == oldp); // if (r) { // *ptr = newp; // } // core_util_critical_section_exit(); // return !r; } #endif #endif