
AT command firmware for MultiTech Dot devices.
Fork of mDot_AT_firmware by
Dot Library Not Included!
Because these example programs can be used for both mDot and xDot devices, the LoRa stack is not included. The libmDot library should be imported if building for mDot devices. The libxDot library should be imported if building for xDot devices. Check the commit messages of the Dot library version used to find the correct mbed-os version to use with it. The mbed-os version must match the version used in that version of Dot library or it will likely cause it to fail to compile or have unexpected problems while running.
Dot Library Version 3 Updates
Dot Library versions 3.x.x require a channel plan to be injected into the stack. The Dot-Examples and Dot-AT-Firmware do this by defining a macro called "CHANNEL_PLAN" that controls the channel plan that will be used in the examples. Available channel plans will be in the Dot Library repository in the plans folder.
Revision 20 and earlier of Dot-Examples and revision 15 and earlier of Dot-AT-Firmware should be used with Dot Library versions prior to 3.0.0.
Fota Library
Th Fota Library must be added to compile for mDot 3.1.0 with Fota support. Latest dev libraries and 3.2.0 release will include Fota with libmDot/libxDot.
AT Firmware Description
This AT Firmware is what ships on mDot and xDot devices. It provides an AT command interface for using the mDot or xDot for LoRa communication.
AT command documentation can be found on Multitech.com.
The firmware changelog can be found here.
The library changelog can be found here.
Dot Libraries
Dot Library Limitations
The commit messages in libmDot-mbed5 and libmDot-dev-mbed5 specify the version of the Dot library the commit contains and the version of mbed-os it was compiled against. We recommend building your application with the version of mbed-os specified in the commit message of the version of the Dot library you're using. This will ensure that you don't run into any runtime issues caused by differences in the mbed-os versions.
Stable and development libraries are available for both mDot and xDot platforms. The library chosen must match the target platform. Compiling for the mDot platform with the xDot library or vice versa will not succeed.
mDot Library
Development library for mDot.
Stable library for mDot.
xDot Library
Development library for xDot.
Stable library for xDot.
Diff: wakeup.c
- Revision:
- 6:e27eaad36a0c
- Parent:
- 5:59f60bedc6df
- Child:
- 7:3c97f3048373
--- a/wakeup.c Tue Aug 18 16:31:53 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,153 +0,0 @@ -#include "stm32f4xx_hal.h" -#include "wakeup.h" - - -static int rtc_inited = 0; -static uint32_t timeout = 10; - -uint32_t wakeup_init(uint32_t seconds) { - RCC_OscInitTypeDef RCC_OscInitStruct; - uint32_t rtc_freq = 0; - - if (rtc_inited) { - if (timeout != seconds) { - timeout = seconds; - HAL_RTCEx_SetWakeUpTimer_IT(&RtcHandle, timeout, RTC_WAKEUPCLOCK_CK_SPRE_16BITS); - } - return 0; - } - rtc_inited = 1; - - RtcHandle.Instance = RTC; - - // Enable Power clock - __PWR_CLK_ENABLE(); - - // Enable access to Backup domain - HAL_PWR_EnableBkUpAccess(); - - uint32_t count = RTC_ReadBackupRegister(RTC_BKP_DR0); - printf("UPLINK: %lu\r\n", count); - - - // Reset Backup domain - __HAL_RCC_BACKUPRESET_FORCE(); - __HAL_RCC_BACKUPRESET_RELEASE(); - - // Enable LSE Oscillator - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; /* Mandatory, otherwise the PLL is reconfigured! */ - RCC_OscInitStruct.LSEState = RCC_LSE_ON; /* External 32.768 kHz clock on OSC_IN/OSC_OUT */ - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) == HAL_OK) { - // Connect LSE to RTC - __HAL_RCC_RTC_CLKPRESCALER(RCC_RTCCLKSOURCE_LSE); - __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE); - rtc_freq = LSE_VALUE; - } else { - // Enable LSI clock - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured! - RCC_OscInitStruct.LSEState = RCC_LSE_OFF; - RCC_OscInitStruct.LSIState = RCC_LSI_ON; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { - //error("RTC error: LSI clock initialization failed."); - } - // Connect LSI to RTC - __HAL_RCC_RTC_CLKPRESCALER(RCC_RTCCLKSOURCE_LSI); - __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI); - // [TODO] This value is LSI typical value. To be measured precisely using a timer input capture - rtc_freq = 32000; - } - - // Enable RTC - __HAL_RCC_RTC_ENABLE(); - - RtcHandle.Init.HourFormat = RTC_HOURFORMAT_24; - RtcHandle.Init.AsynchPrediv = 127; - RtcHandle.Init.SynchPrediv = (rtc_freq / 128) - 1; - RtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE; - RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; - RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; - - if (HAL_RTC_Init(&RtcHandle) != HAL_OK) { - //error("RTC error: RTC initialization failed."); - } - - timeout = seconds; - HAL_RTCEx_SetWakeUpTimer_IT(&RtcHandle, timeout, RTC_WAKEUPCLOCK_CK_SPRE_16BITS); - - return count; -} - -void wakeup_clear(void) -{ - __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&RtcHandle, RTC_FLAG_WUTF); -} - -uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR) -{ - __IO uint32_t tmp = 0; - - // Check the parameters - assert_param(IS_RTC_BKP(RTC_BKP_DR)); - tmp = RTC_BASE + 0x50; - tmp += (RTC_BKP_DR * 4); - // Read the specified register - return (*(__IO uint32_t *)tmp); -} - -void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data) -{ - __IO uint32_t tmp = 0; - - // Check the parameters/ - assert_param(IS_RTC_BKP(RTC_BKP_DR)); - tmp = RTC_BASE + 0x50; - tmp += (RTC_BKP_DR * 4); - // Write the specified register/ - *(__IO uint32_t *)tmp = (uint32_t)Data; -} - - -uint8_t TM_WATCHDOG_Init(uint16_t reload) { - uint8_t result = 0; - - /* Check if the system has resumed from IWDG reset */ - if (RCC->CSR & (0x20000000)) { - /* Reset by IWDG */ - result = 1; - - /* Clear reset flags */ - RCC->CSR |= RCC_CSR_RMVF; - } - - /* Enable write access to IWDG_PR and IWDG_RLR registers */ - IWDG->KR = 0x5555; - - /* IWDG counter clock: LSI/32 = 1024Hz */ - IWDG->PR = 0x03; - - reload = 4095; - - printf("WATCHDOG RELOAD: %lu\r\n", reload); - /* Set reload */ - IWDG->RLR = reload; - - /* Reload IWDG counter */ - IWDG->KR = 0xAAAA; - - /* Enable IWDG (the LSI oscillator will be enabled by hardware) */ - IWDG->KR = 0xCCCC; - - /* Return status */ - return result; -} - -void TM_WATCHDOG_Disable(void) { - IWDG->KR = 0x0000; -} - -void TM_WATCHDOG_Reset(void) { - /* Reload IWDG counter */ - IWDG->KR = 0xAAAA; -}