Skip to content

Commit a5bef60

Browse files
Cruz Monrreal IICruz Monrreal II
authored andcommitted
Revert "Merge pull request #8272 from NXPmicro/Ensure_RTC_OSC_Start"
This reverts commit 3d859ca, reversing changes made to 03f4623.
1 parent 9aef9d3 commit a5bef60

File tree

17 files changed

+116
-376
lines changed

17 files changed

+116
-376
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/TARGET_FRDM/mbed_overrides.c

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,12 @@
1717

1818
#define CRC16
1919
#include "crc.h"
20-
#include "fsl_rtc.h"
2120
#include "fsl_clock_config.h"
2221

2322
// called before main
2423
void mbed_sdk_init()
2524
{
26-
rtc_config_t rtc_basic_config;
27-
uint32_t u32cTPR_counter = 0;
28-
2925
BOARD_BootClockRUN();
30-
31-
CLOCK_EnableClock(kCLOCK_Rtc0);
32-
33-
/* Check if the Rtc oscillator is enabled */
34-
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
35-
/* Setup the 32K RTC OSC */
36-
RTC_Init(RTC, &rtc_basic_config);
37-
38-
/* Enable the RTC 32KHz oscillator */
39-
RTC->CR |= RTC_CR_OSCE_MASK;
40-
41-
/* Start the RTC time counter */
42-
RTC_StartTimer(RTC);
43-
44-
/* Verify TPR register reaches 4096 counts */
45-
while (u32cTPR_counter < 4096) {
46-
u32cTPR_counter = RTC->TPR;
47-
}
48-
/* 32kHz Oscillator is ready. */
49-
RTC_Deinit(RTC);
50-
}
5126
}
5227

5328
// Change the NMI pin to an input. This allows NMI pin to
@@ -59,6 +34,13 @@ void NMI_Handler(void)
5934
gpio_init_in(&gpio, PTA4);
6035
}
6136

37+
// Enable the RTC oscillator if available on the board
38+
void rtc_setup_oscillator(RTC_Type *base)
39+
{
40+
/* Enable the RTC oscillator */
41+
RTC->CR |= RTC_CR_OSCE_MASK;
42+
}
43+
6244
// Provide ethernet devices with a semi-unique MAC address from the UUID
6345
void mbed_mac_address(char *mac)
6446
{
@@ -73,7 +55,7 @@ void mbed_mac_address(char *mac)
7355

7456
// generate three CRC16's using different slices of the UUID
7557
MAC[0] = crcSlow((const uint8_t *)UID, 8); // most significant half-word
76-
MAC[1] = crcSlow((const uint8_t *)UID, 12);
58+
MAC[1] = crcSlow((const uint8_t *)UID, 12);
7759
MAC[2] = crcSlow((const uint8_t *)UID, 16); // least significant half word
7860

7961
// The network stack expects an array of 6 bytes

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/TARGET_FRDM/mbed_overrides.c

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,12 @@
1414
* limitations under the License.
1515
*/
1616
#include "gpio_api.h"
17-
#include "fsl_rtc.h"
1817
#include "fsl_clock_config.h"
1918

2019
// called before main
2120
void mbed_sdk_init()
2221
{
23-
rtc_config_t rtc_basic_config;
24-
uint32_t u32cTPR_counter = 0;
25-
2622
BOARD_BootClockRUN();
27-
28-
CLOCK_EnableClock(kCLOCK_Rtc0);
29-
30-
/* Check if the Rtc oscillator is enabled */
31-
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
32-
/* Setup the 32K RTC OSC */
33-
RTC_Init(RTC, &rtc_basic_config);
34-
35-
/* Enable the RTC 32KHz oscillator */
36-
RTC->CR |= RTC_CR_OSCE_MASK;
37-
38-
/* Start the RTC time counter */
39-
RTC_StartTimer(RTC);
40-
41-
/* Verify TPR register reaches 4096 counts */
42-
while (u32cTPR_counter < 4096) {
43-
u32cTPR_counter = RTC->TPR;
44-
}
45-
/* 32kHz Oscillator is ready. */
46-
RTC_Deinit(RTC);
47-
}
4823
}
4924

5025
// Change the NMI pin to an input. This allows NMI pin to
@@ -56,6 +31,13 @@ void NMI_Handler(void)
5631
gpio_init_in(&gpio, PTA4);
5732
}
5833

34+
// Enable the RTC oscillator if available on the board
35+
void rtc_setup_oscillator(RTC_Type *base)
36+
{
37+
/* Enable the RTC oscillator */
38+
RTC->CR |= RTC_CR_OSCE_MASK;
39+
}
40+
5941
// Set the UART clock source
6042
void serial_clock_init(void)
6143
{

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/TARGET_UBRIDGE/mbed_overrides.c

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,13 @@
1717
#include "fsl_smc.h"
1818
#include "fsl_rcm.h"
1919
#include "fsl_pmc.h"
20-
#include "fsl_rtc.h"
2120
#include "fsl_clock_config.h"
2221

2322
//!< this contains the wakeup source
2423
rcm_reset_source_t kinetisResetSource;
2524

2625
// called before main
27-
void mbed_sdk_init()
28-
{
29-
rtc_config_t rtc_basic_config;
30-
uint32_t u32cTPR_counter = 0;
31-
26+
void mbed_sdk_init() {
3227
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
3328

3429
// check the power mode source
@@ -41,26 +36,6 @@ void mbed_sdk_init()
4136

4237
BOARD_BootClockRUN();
4338

44-
CLOCK_EnableClock(kCLOCK_Rtc0);
45-
46-
/* Check if the Rtc oscillator is enabled */
47-
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
48-
/* Setup the 32K RTC OSC */
49-
RTC_Init(RTC, &rtc_basic_config);
50-
51-
/* Enable the RTC 32KHz oscillator */
52-
RTC->CR |= RTC_CR_OSCE_MASK;
53-
54-
/* Start the RTC time counter */
55-
RTC_StartTimer(RTC);
56-
57-
/* Verify TPR register reaches 4096 counts */
58-
while (u32cTPR_counter < 4096) {
59-
u32cTPR_counter = RTC->TPR;
60-
}
61-
/* 32kHz Oscillator is ready. */
62-
RTC_Deinit(RTC);
63-
}
6439
}
6540

6641
// Change the NMI pin to an input. This allows NMI pin to
@@ -72,6 +47,13 @@ void NMI_Handler(void)
7247
gpio_init_in(&gpio, PTA4);
7348
}
7449

50+
// Enable the RTC oscillator if available on the board
51+
void rtc_setup_oscillator(RTC_Type *base)
52+
{
53+
/* Enable the RTC oscillator */
54+
RTC->CR |= RTC_CR_OSCE_MASK;
55+
}
56+
7557
// Set the UART clock source
7658
void serial_clock_init(void)
7759
{

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL27Z/TARGET_FRDM/mbed_overrides.c

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,22 @@
1515
*/
1616
#include "gpio_api.h"
1717
#include "pinmap.h"
18-
#include "fsl_rtc.h"
1918
#include "fsl_clock_config.h"
2019

2120
// called before main - implement here if board needs it otherwise, let
2221
// the application override this if necessary
2322
void mbed_sdk_init()
2423
{
25-
rtc_config_t rtc_basic_config;
26-
uint32_t u32cTPR_counter = 0;
27-
2824
BOARD_BootClockRUN();
2925
/* Set the TPM clock source to be IRC48M, do not change as TPM2 is used for the usticker */
3026
CLOCK_SetTpmClock(1U);
27+
}
3128

32-
CLOCK_EnableClock(kCLOCK_Rtc0);
33-
34-
/* Check if the Rtc oscillator is enabled */
35-
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
36-
/* Setup the 32K RTC OSC */
37-
RTC_Init(RTC, &rtc_basic_config);
38-
39-
/* Enable the RTC 32KHz oscillator */
40-
RTC->CR |= RTC_CR_OSCE_MASK;
41-
42-
/* Start the RTC time counter */
43-
RTC_StartTimer(RTC);
44-
45-
/* Verify TPR register reaches 4096 counts */
46-
while (u32cTPR_counter < 4096) {
47-
u32cTPR_counter = RTC->TPR;
48-
}
49-
/* 32kHz Oscillator is ready. */
50-
RTC_Deinit(RTC);
51-
}
29+
// Enable the RTC oscillator if available on the board
30+
void rtc_setup_oscillator(RTC_Type *base)
31+
{
32+
/* Enable the RTC oscillator */
33+
RTC->CR |= RTC_CR_OSCE_MASK;
5234
}
5335

5436
// Change the NMI pin to an input. This allows NMI pin to

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL43Z/TARGET_FRDM/mbed_overrides.c

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,22 @@
1515
*/
1616
#include "gpio_api.h"
1717
#include "pinmap.h"
18-
#include "fsl_rtc.h"
1918
#include "fsl_clock_config.h"
2019

2120
// called before main - implement here if board needs it otherwise, let
2221
// the application override this if necessary
2322
void mbed_sdk_init()
2423
{
25-
rtc_config_t rtc_basic_config;
26-
uint32_t u32cTPR_counter = 0;
27-
2824
BOARD_BootClockRUN();
2925
/* Set the TPM clock source to be IRC48M, do not change as TPM2 is used for the usticker */
3026
CLOCK_SetTpmClock(1U);
27+
}
3128

32-
CLOCK_EnableClock(kCLOCK_Rtc0);
33-
34-
/* Check if the Rtc oscillator is enabled */
35-
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
36-
/* Setup the 32K RTC OSC */
37-
RTC_Init(RTC, &rtc_basic_config);
38-
39-
/* Enable the RTC 32KHz oscillator */
40-
RTC->CR |= RTC_CR_OSCE_MASK;
41-
42-
/* Start the RTC time counter */
43-
RTC_StartTimer(RTC);
44-
45-
/* Verify TPR register reaches 4096 counts */
46-
while (u32cTPR_counter < 4096) {
47-
u32cTPR_counter = RTC->TPR;
48-
}
49-
/* 32kHz Oscillator is ready. */
50-
RTC_Deinit(RTC);
51-
}
29+
// Enable the RTC oscillator if available on the board
30+
void rtc_setup_oscillator(RTC_Type *base)
31+
{
32+
/* Enable the RTC oscillator */
33+
RTC->CR |= RTC_CR_OSCE_MASK;
5234
}
5335

5436
// Change the NMI pin to an input. This allows NMI pin to

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/TARGET_FRDM/mbed_overrides.c

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,20 @@
1515
*/
1616
#include "gpio_api.h"
1717
#include "pinmap.h"
18-
#include "fsl_rtc.h"
1918
#include "fsl_clock_config.h"
2019

2120
// called before main - implement here if board needs it otherwise, let
2221
// the application override this if necessary
2322
void mbed_sdk_init()
2423
{
25-
rtc_config_t rtc_basic_config;
26-
uint32_t u32cTPR_counter = 0;
27-
2824
BOARD_BootClockRUN();
25+
}
2926

30-
CLOCK_EnableClock(kCLOCK_Rtc0);
31-
32-
/* Check if the Rtc oscillator is enabled */
33-
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
34-
/* Setup the 32K RTC OSC */
35-
RTC_Init(RTC, &rtc_basic_config);
36-
37-
/* Enable the RTC 32KHz oscillator */
38-
RTC->CR |= RTC_CR_OSCE_MASK;
39-
40-
/* Start the RTC time counter */
41-
RTC_StartTimer(RTC);
42-
43-
/* Verify TPR register reaches 4096 counts */
44-
while (u32cTPR_counter < 4096) {
45-
u32cTPR_counter = RTC->TPR;
46-
}
47-
/* 32kHz Oscillator is ready. */
48-
RTC_Deinit(RTC);
49-
}
27+
// Enable the RTC oscillator if available on the board
28+
void rtc_setup_oscillator(RTC_Type *base)
29+
{
30+
/* Enable the RTC oscillator */
31+
RTC->CR |= RTC_CR_OSCE_MASK;
5032
}
5133

5234
// Change the NMI pin to an input. This allows NMI pin to

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/TARGET_USENSE/mbed_overrides.c

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,13 @@
1717
#include "fsl_smc.h"
1818
#include "fsl_rcm.h"
1919
#include "fsl_pmc.h"
20-
#include "fsl_rtc.h"
2120
#include "fsl_clock_config.h"
2221

2322
//!< this contains the wakeup source
2423
rcm_reset_source_t kinetisResetSource;
2524

2625
// called before main
27-
void mbed_sdk_init()
28-
{
29-
rtc_config_t rtc_basic_config;
30-
uint32_t u32cTPR_counter = 0;
31-
26+
void mbed_sdk_init() {
3227
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
3328

3429
// check the power mode source
@@ -40,27 +35,6 @@ void mbed_sdk_init()
4035
}
4136

4237
BOARD_BootClockRUN();
43-
44-
CLOCK_EnableClock(kCLOCK_Rtc0);
45-
46-
/* Check if the Rtc oscillator is enabled */
47-
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) {
48-
/* Setup the 32K RTC OSC */
49-
RTC_Init(RTC, &rtc_basic_config);
50-
51-
/* Enable the RTC 32KHz oscillator */
52-
RTC->CR |= RTC_CR_OSCE_MASK;
53-
54-
/* Start the RTC time counter */
55-
RTC_StartTimer(RTC);
56-
57-
/* Verify TPR register reaches 4096 counts */
58-
while (u32cTPR_counter < 4096) {
59-
u32cTPR_counter = RTC->TPR;
60-
}
61-
/* 32kHz Oscillator is ready. */
62-
RTC_Deinit(RTC);
63-
}
6438
}
6539

6640
// Change the NMI pin to an input. This allows NMI pin to
@@ -72,6 +46,15 @@ void NMI_Handler(void)
7246
gpio_init_in(&gpio, PTA4);
7347
}
7448

49+
#if DEVICE_RTC || DEVICE_LPTICKER
50+
// Enable the RTC oscillator if available on the board
51+
void rtc_setup_oscillator(RTC_Type *base)
52+
{
53+
/* Enable the RTC oscillator */
54+
RTC->CR |= RTC_CR_OSCE_MASK;
55+
}
56+
#endif
57+
7558
// Set the UART clock source
7659
void serial_clock_init(void)
7760
{

0 commit comments

Comments
 (0)