mirror of https://github.com/ARMmbed/mbed-os.git
Revert "Merge pull request #8272 from NXPmicro/Ensure_RTC_OSC_Start"
This reverts commitpull/8826/head3d859ca1d6
, reversing changes made to03f4623b80
.
parent
9aef9d3661
commit
a5bef60afe
|
@ -17,37 +17,12 @@
|
||||||
|
|
||||||
#define CRC16
|
#define CRC16
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main
|
// called before main
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
|
||||||
|
|
||||||
/* Check if the Rtc oscillator is enabled */
|
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
|
||||||
/* Setup the 32K RTC OSC */
|
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
@ -59,6 +34,13 @@ void NMI_Handler(void)
|
||||||
gpio_init_in(&gpio, PTA4);
|
gpio_init_in(&gpio, PTA4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
|
{
|
||||||
|
/* Enable the RTC oscillator */
|
||||||
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
// Provide ethernet devices with a semi-unique MAC address from the UUID
|
// Provide ethernet devices with a semi-unique MAC address from the UUID
|
||||||
void mbed_mac_address(char *mac)
|
void mbed_mac_address(char *mac)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +55,7 @@ void mbed_mac_address(char *mac)
|
||||||
|
|
||||||
// generate three CRC16's using different slices of the UUID
|
// generate three CRC16's using different slices of the UUID
|
||||||
MAC[0] = crcSlow((const uint8_t *)UID, 8); // most significant half-word
|
MAC[0] = crcSlow((const uint8_t *)UID, 8); // most significant half-word
|
||||||
MAC[1] = crcSlow((const uint8_t *)UID, 12);
|
MAC[1] = crcSlow((const uint8_t *)UID, 12);
|
||||||
MAC[2] = crcSlow((const uint8_t *)UID, 16); // least significant half word
|
MAC[2] = crcSlow((const uint8_t *)UID, 16); // least significant half word
|
||||||
|
|
||||||
// The network stack expects an array of 6 bytes
|
// The network stack expects an array of 6 bytes
|
||||||
|
|
|
@ -14,37 +14,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "gpio_api.h"
|
#include "gpio_api.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main
|
// called before main
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
|
||||||
|
|
||||||
/* Check if the Rtc oscillator is enabled */
|
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
|
||||||
/* Setup the 32K RTC OSC */
|
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
@ -56,6 +31,13 @@ void NMI_Handler(void)
|
||||||
gpio_init_in(&gpio, PTA4);
|
gpio_init_in(&gpio, PTA4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
|
{
|
||||||
|
/* Enable the RTC oscillator */
|
||||||
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the UART clock source
|
// Set the UART clock source
|
||||||
void serial_clock_init(void)
|
void serial_clock_init(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,18 +17,13 @@
|
||||||
#include "fsl_smc.h"
|
#include "fsl_smc.h"
|
||||||
#include "fsl_rcm.h"
|
#include "fsl_rcm.h"
|
||||||
#include "fsl_pmc.h"
|
#include "fsl_pmc.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
//!< this contains the wakeup source
|
//!< this contains the wakeup source
|
||||||
rcm_reset_source_t kinetisResetSource;
|
rcm_reset_source_t kinetisResetSource;
|
||||||
|
|
||||||
// called before main
|
// called before main
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init() {
|
||||||
{
|
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
|
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
|
||||||
|
|
||||||
// check the power mode source
|
// check the power mode source
|
||||||
|
@ -41,26 +36,6 @@ void mbed_sdk_init()
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
|
||||||
|
|
||||||
/* Check if the Rtc oscillator is enabled */
|
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
|
||||||
/* Setup the 32K RTC OSC */
|
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
@ -72,6 +47,13 @@ void NMI_Handler(void)
|
||||||
gpio_init_in(&gpio, PTA4);
|
gpio_init_in(&gpio, PTA4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
|
{
|
||||||
|
/* Enable the RTC oscillator */
|
||||||
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the UART clock source
|
// Set the UART clock source
|
||||||
void serial_clock_init(void)
|
void serial_clock_init(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,40 +15,22 @@
|
||||||
*/
|
*/
|
||||||
#include "gpio_api.h"
|
#include "gpio_api.h"
|
||||||
#include "pinmap.h"
|
#include "pinmap.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main - implement here if board needs it otherwise, let
|
// called before main - implement here if board needs it otherwise, let
|
||||||
// the application override this if necessary
|
// the application override this if necessary
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
/* Set the TPM clock source to be IRC48M, do not change as TPM2 is used for the usticker */
|
/* Set the TPM clock source to be IRC48M, do not change as TPM2 is used for the usticker */
|
||||||
CLOCK_SetTpmClock(1U);
|
CLOCK_SetTpmClock(1U);
|
||||||
|
}
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
/* Check if the Rtc oscillator is enabled */
|
{
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
/* Enable the RTC oscillator */
|
||||||
/* Setup the 32K RTC OSC */
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
|
|
@ -15,40 +15,22 @@
|
||||||
*/
|
*/
|
||||||
#include "gpio_api.h"
|
#include "gpio_api.h"
|
||||||
#include "pinmap.h"
|
#include "pinmap.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main - implement here if board needs it otherwise, let
|
// called before main - implement here if board needs it otherwise, let
|
||||||
// the application override this if necessary
|
// the application override this if necessary
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
/* Set the TPM clock source to be IRC48M, do not change as TPM2 is used for the usticker */
|
/* Set the TPM clock source to be IRC48M, do not change as TPM2 is used for the usticker */
|
||||||
CLOCK_SetTpmClock(1U);
|
CLOCK_SetTpmClock(1U);
|
||||||
|
}
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
/* Check if the Rtc oscillator is enabled */
|
{
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
/* Enable the RTC oscillator */
|
||||||
/* Setup the 32K RTC OSC */
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
|
|
@ -15,38 +15,20 @@
|
||||||
*/
|
*/
|
||||||
#include "gpio_api.h"
|
#include "gpio_api.h"
|
||||||
#include "pinmap.h"
|
#include "pinmap.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main - implement here if board needs it otherwise, let
|
// called before main - implement here if board needs it otherwise, let
|
||||||
// the application override this if necessary
|
// the application override this if necessary
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
|
}
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
/* Check if the Rtc oscillator is enabled */
|
{
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
/* Enable the RTC oscillator */
|
||||||
/* Setup the 32K RTC OSC */
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
|
|
@ -17,18 +17,13 @@
|
||||||
#include "fsl_smc.h"
|
#include "fsl_smc.h"
|
||||||
#include "fsl_rcm.h"
|
#include "fsl_rcm.h"
|
||||||
#include "fsl_pmc.h"
|
#include "fsl_pmc.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
//!< this contains the wakeup source
|
//!< this contains the wakeup source
|
||||||
rcm_reset_source_t kinetisResetSource;
|
rcm_reset_source_t kinetisResetSource;
|
||||||
|
|
||||||
// called before main
|
// called before main
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init() {
|
||||||
{
|
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
|
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
|
||||||
|
|
||||||
// check the power mode source
|
// check the power mode source
|
||||||
|
@ -40,27 +35,6 @@ void mbed_sdk_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
|
||||||
|
|
||||||
/* Check if the Rtc oscillator is enabled */
|
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
|
||||||
/* Setup the 32K RTC OSC */
|
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
@ -72,6 +46,15 @@ void NMI_Handler(void)
|
||||||
gpio_init_in(&gpio, PTA4);
|
gpio_init_in(&gpio, PTA4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEVICE_RTC || DEVICE_LPTICKER
|
||||||
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
|
{
|
||||||
|
/* Enable the RTC oscillator */
|
||||||
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Set the UART clock source
|
// Set the UART clock source
|
||||||
void serial_clock_init(void)
|
void serial_clock_init(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,38 +14,20 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "gpio_api.h"
|
#include "gpio_api.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main - implement here if board needs it otherwise, let
|
// called before main - implement here if board needs it otherwise, let
|
||||||
// the application override this if necessary
|
// the application override this if necessary
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
|
}
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
/* Check if the Rtc oscillator is enabled */
|
{
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
/* Enable the RTC oscillator */
|
||||||
/* Setup the 32K RTC OSC */
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
|
|
@ -14,40 +14,22 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "gpio_api.h"
|
#include "gpio_api.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main - implement here if board needs it otherwise, let
|
// called before main - implement here if board needs it otherwise, let
|
||||||
// the application override this if necessary
|
// the application override this if necessary
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
/* Set the TPM clock source to be OSCERCLK, do not change as TPM2 is used for the usticker */
|
/* Set the TPM clock source to be OSCERCLK, do not change as TPM2 is used for the usticker */
|
||||||
CLOCK_SetTpmClock(2U);
|
CLOCK_SetTpmClock(2U);
|
||||||
|
}
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
/* Check if the Rtc oscillator is enabled */
|
{
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
/* Enable the RTC oscillator */
|
||||||
/* Setup the 32K RTC OSC */
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
|
|
@ -15,39 +15,21 @@
|
||||||
*/
|
*/
|
||||||
#include "gpio_api.h"
|
#include "gpio_api.h"
|
||||||
#include "pinmap.h"
|
#include "pinmap.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main - implement here if board needs it otherwise, let
|
// called before main - implement here if board needs it otherwise, let
|
||||||
// the application override this if necessary
|
// the application override this if necessary
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
pin_function(PTA2, 1); //By default the GREEN LED is enabled. This disables it
|
pin_function(PTA2, 1); //By default the GREEN LED is enabled. This disables it
|
||||||
|
}
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
/* Check if the Rtc oscillator is enabled */
|
{
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
/* Enable the RTC oscillator */
|
||||||
/* Setup the 32K RTC OSC */
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
@ -58,4 +40,3 @@ void NMI_Handler(void)
|
||||||
gpio_t gpio;
|
gpio_t gpio;
|
||||||
gpio_init_in(&gpio, PTA4);
|
gpio_init_in(&gpio, PTA4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,37 +17,12 @@
|
||||||
|
|
||||||
#define CRC16
|
#define CRC16
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main
|
// called before main
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
|
||||||
|
|
||||||
/* Check if the Rtc oscillator is enabled */
|
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
|
||||||
/* Setup the 32K RTC OSC */
|
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
@ -59,3 +34,10 @@ void NMI_Handler(void)
|
||||||
gpio_init_in(&gpio, PTA4);
|
gpio_init_in(&gpio, PTA4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
|
{
|
||||||
|
/* Enable the RTC oscillator */
|
||||||
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,37 +17,12 @@
|
||||||
|
|
||||||
#define CRC16
|
#define CRC16
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main
|
// called before main
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
|
||||||
|
|
||||||
/* Check if the Rtc oscillator is enabled */
|
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
|
||||||
/* Setup the 32K RTC OSC */
|
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
@ -59,6 +34,13 @@ void NMI_Handler(void)
|
||||||
gpio_init_in(&gpio, PTA4);
|
gpio_init_in(&gpio, PTA4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
|
{
|
||||||
|
/* Enable the RTC oscillator */
|
||||||
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
// Provide ethernet devices with a semi-unique MAC address from the UUID
|
// Provide ethernet devices with a semi-unique MAC address from the UUID
|
||||||
void mbed_mac_address(char *mac)
|
void mbed_mac_address(char *mac)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +55,7 @@ void mbed_mac_address(char *mac)
|
||||||
|
|
||||||
// generate three CRC16's using different slices of the UUID
|
// generate three CRC16's using different slices of the UUID
|
||||||
MAC[0] = crcSlow((const uint8_t *)UID, 8); // most significant half-word
|
MAC[0] = crcSlow((const uint8_t *)UID, 8); // most significant half-word
|
||||||
MAC[1] = crcSlow((const uint8_t *)UID, 12);
|
MAC[1] = crcSlow((const uint8_t *)UID, 12);
|
||||||
MAC[2] = crcSlow((const uint8_t *)UID, 16); // least significant half word
|
MAC[2] = crcSlow((const uint8_t *)UID, 16); // least significant half word
|
||||||
|
|
||||||
// The network stack expects an array of 6 bytes
|
// The network stack expects an array of 6 bytes
|
||||||
|
|
|
@ -14,36 +14,19 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "gpio_api.h"
|
#include "gpio_api.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main
|
// called before main
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
|
}
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
|
||||||
|
// Enable the RTC oscillator if available on the board
|
||||||
/* Check if the Rtc oscillator is enabled */
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
{
|
||||||
/* Setup the 32K RTC OSC */
|
/* Enable the RTC oscillator */
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,36 +14,16 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "gpio_api.h"
|
#include "gpio_api.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main
|
// called before main
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
|
||||||
|
|
||||||
/* Check if the Rtc oscillator is enabled */
|
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
|
||||||
/* Setup the 32K RTC OSC */
|
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
|
{
|
||||||
|
/* Enable the RTC oscillator */
|
||||||
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
|
}
|
||||||
|
|
|
@ -17,37 +17,12 @@
|
||||||
|
|
||||||
#define CRC16
|
#define CRC16
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
#include "fsl_rtc.h"
|
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
// called before main
|
// called before main
|
||||||
void mbed_sdk_init()
|
void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
rtc_config_t rtc_basic_config;
|
|
||||||
uint32_t u32cTPR_counter = 0;
|
|
||||||
|
|
||||||
BOARD_BootClockRUN();
|
BOARD_BootClockRUN();
|
||||||
|
|
||||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
|
||||||
|
|
||||||
/* Check if the Rtc oscillator is enabled */
|
|
||||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
|
|
||||||
/* Setup the 32K RTC OSC */
|
|
||||||
RTC_Init(RTC, &rtc_basic_config);
|
|
||||||
|
|
||||||
/* Enable the RTC 32KHz oscillator */
|
|
||||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
|
||||||
|
|
||||||
/* Start the RTC time counter */
|
|
||||||
RTC_StartTimer(RTC);
|
|
||||||
|
|
||||||
/* Verify TPR register reaches 4096 counts */
|
|
||||||
while (u32cTPR_counter < 4096) {
|
|
||||||
u32cTPR_counter = RTC->TPR;
|
|
||||||
}
|
|
||||||
/* 32kHz Oscillator is ready. */
|
|
||||||
RTC_Deinit(RTC);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the NMI pin to an input. This allows NMI pin to
|
// Change the NMI pin to an input. This allows NMI pin to
|
||||||
|
@ -59,6 +34,13 @@ void NMI_Handler(void)
|
||||||
gpio_init_in(&gpio, PTA4);
|
gpio_init_in(&gpio, PTA4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable the RTC oscillator if available on the board
|
||||||
|
void rtc_setup_oscillator(RTC_Type *base)
|
||||||
|
{
|
||||||
|
/* Enable the RTC oscillator */
|
||||||
|
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
// Provide ethernet devices with a semi-unique MAC address from the UUID
|
// Provide ethernet devices with a semi-unique MAC address from the UUID
|
||||||
void mbed_mac_address(char *mac)
|
void mbed_mac_address(char *mac)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +55,7 @@ void mbed_mac_address(char *mac)
|
||||||
|
|
||||||
// generate three CRC16's using different slices of the UUID
|
// generate three CRC16's using different slices of the UUID
|
||||||
MAC[0] = crcSlow((const uint8_t *)UID, 8); // most significant half-word
|
MAC[0] = crcSlow((const uint8_t *)UID, 8); // most significant half-word
|
||||||
MAC[1] = crcSlow((const uint8_t *)UID, 12);
|
MAC[1] = crcSlow((const uint8_t *)UID, 12);
|
||||||
MAC[2] = crcSlow((const uint8_t *)UID, 16); // least significant half word
|
MAC[2] = crcSlow((const uint8_t *)UID, 16); // least significant half word
|
||||||
|
|
||||||
// The network stack expects an array of 6 bytes
|
// The network stack expects an array of 6 bytes
|
||||||
|
@ -94,3 +76,5 @@ void mbed_mac_address(char *mac)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ const ticker_info_t* lp_ticker_get_info()
|
||||||
|
|
||||||
static bool lp_ticker_inited = false;
|
static bool lp_ticker_inited = false;
|
||||||
|
|
||||||
|
extern void rtc_setup_oscillator(RTC_Type *base);
|
||||||
|
|
||||||
static void lptmr_isr(void)
|
static void lptmr_isr(void)
|
||||||
{
|
{
|
||||||
LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
|
LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
|
||||||
|
@ -50,6 +52,9 @@ void lp_ticker_init(void)
|
||||||
/* Setup high resolution clock - LPTMR */
|
/* Setup high resolution clock - LPTMR */
|
||||||
LPTMR_GetDefaultConfig(&lptmrConfig);
|
LPTMR_GetDefaultConfig(&lptmrConfig);
|
||||||
|
|
||||||
|
/* Setup the RTC 32KHz oscillator */
|
||||||
|
CLOCK_EnableClock(kCLOCK_Rtc0);
|
||||||
|
rtc_setup_oscillator(RTC);
|
||||||
/* Use 32kHz drive */
|
/* Use 32kHz drive */
|
||||||
CLOCK_SetXtal32Freq(OSC32K_CLK_HZ);
|
CLOCK_SetXtal32Freq(OSC32K_CLK_HZ);
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "fsl_rtc.h"
|
#include "fsl_rtc.h"
|
||||||
#include "PeripheralPins.h"
|
#include "PeripheralPins.h"
|
||||||
|
|
||||||
|
extern void rtc_setup_oscillator(RTC_Type *base);
|
||||||
|
|
||||||
static bool rtc_time_set = false;
|
static bool rtc_time_set = false;
|
||||||
|
|
||||||
void rtc_init(void)
|
void rtc_init(void)
|
||||||
|
@ -30,6 +32,8 @@ void rtc_init(void)
|
||||||
RTC_GetDefaultConfig(&rtcConfig);
|
RTC_GetDefaultConfig(&rtcConfig);
|
||||||
RTC_Init(RTC, &rtcConfig);
|
RTC_Init(RTC, &rtcConfig);
|
||||||
|
|
||||||
|
/* Setup the RTC 32KHz oscillator */
|
||||||
|
rtc_setup_oscillator(RTC);
|
||||||
RTC_StartTimer(RTC);
|
RTC_StartTimer(RTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue