Skip to content

Commit 54e1ec6

Browse files
author
Cruz Monrreal
authored
Merge pull request ARMmbed#10213 from d-kato/rza1xx_wait_ns
GR_LYCHEE,RZ_A1H,VK_RZ_A1H: Fix greentea ticker test case failures
2 parents be38d95 + 090fcb0 commit 54e1ec6

File tree

10 files changed

+68
-110
lines changed

10 files changed

+68
-110
lines changed

platform/mbed_wait_api_no_rtos.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ void wait_us(int us)
7575
#endif
7676
#elif defined __CORTEX_A
7777
#if __CORTEX_A == 9
78-
// Cortex-A9 is dual-issue, so let's assume same performance as Cortex-M7.
79-
// TODO - test.
80-
#define LOOP_SCALER 2000
78+
// Cortex-A9 can dual issue for 3 cycles per iteration (SUB,NOP) = 1, (NOP,BCS) = 2
79+
#define LOOP_SCALER 3000
8180
#endif
8281
#endif
8382

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_GR_LYCHEE/device/os_tick_ostm.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
2626

2727
#include "os_tick.h"
2828
#include "irq_ctrl.h"
29-
30-
#include <MBRZA1LU.h>
31-
32-
#include <cmsis.h>
29+
#include "cmsis.h"
30+
#include "mbed_drv_cfg.h"
3331

3432

3533
// Define OS TImer interrupt priority
@@ -62,15 +60,15 @@ int32_t OS_Tick_Setup (uint32_t freq, IRQHandler_t handler)
6260
// Get CPG.FRQCR[IFC] bits
6361
clock = (CPG.FRQCR >> 8) & 0x03;
6462

65-
// Determine Divider 2 output clock by using SystemCoreClock
63+
// Determine Divider 2 output clock by using RENESAS_RZ_A1_P0_CLK
6664
if (clock == 0x03U) {
67-
clock = (SystemCoreClock * 3U);
65+
clock = (RENESAS_RZ_A1_P0_CLK * 3U);
6866
}
6967
else if (clock == 0x01U) {
70-
clock = (SystemCoreClock * 3U)/2U;
68+
clock = (RENESAS_RZ_A1_P0_CLK * 3U)/2U;
7169
}
7270
else {
73-
clock = SystemCoreClock;
71+
clock = RENESAS_RZ_A1_P0_CLK;
7472
}
7573

7674
// Determine tick frequency
@@ -144,7 +142,8 @@ void OS_Tick_Enable (void)
144142
}
145143

146144
/// Disable OS Tick.
147-
void OS_Tick_Disable (void) {
145+
void OS_Tick_Disable (void)
146+
{
148147

149148
// Stop the OSTM counter
150149
OSTM.OSTMnTT = 0x01U;
@@ -156,7 +155,7 @@ void OS_Tick_Disable (void) {
156155
}
157156

158157
// Acknowledge OS Tick IRQ.
159-
void OS_Tick_AcknowledgeIRQ (void)
158+
void OS_Tick_AcknowledgeIRQ (void)
160159
{
161160
IRQ_ClearPending (OSTM_IRQn);
162161
}

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_GR_LYCHEE/device/system_RZ_A1LU.c

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@
2626
* limitations under the License.
2727
*/
2828

29-
#include <RZ_A1LU.h>
29+
#include "RZ_A1LU.h"
3030
#include "RZ_A1_Init.h"
3131
#include "irq_ctrl.h"
32-
33-
#define CS2_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFD040)
34-
#define CS3_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFE040)
35-
#define GPIO_PORT0_BOOTMODE_BITMASK (0x000fu)
32+
#include "mbed_drv_cfg.h"
3633

3734
/*
3835
Port 0 (P0) MD pin assignment
@@ -45,30 +42,17 @@
4542
/*----------------------------------------------------------------------------
4643
System Core Clock Variable
4744
*----------------------------------------------------------------------------*/
48-
uint32_t SystemCoreClock = CM1_RENESAS_RZ_A1_P0_CLK;
45+
uint32_t SystemCoreClock = RENESAS_RZ_A1_SYS_CLK;
4946

5047
/*----------------------------------------------------------------------------
5148
System Core Clock update function
5249
*----------------------------------------------------------------------------*/
5350
void SystemCoreClockUpdate (void)
5451
{
5552
uint32_t freq;
56-
uint16_t mode;
5753
uint16_t ifc;
5854

59-
mode = (GPIO.PPR0 >> 2U) & 0x01U;
60-
61-
if (mode == 0) {
62-
/* Clock Mode 0 */
63-
/* CLKIN is between 10MHz and 13.33MHz */
64-
/* Divider 1 uses 1/1 ratio, PLL x30 is ON */
65-
freq = CM0_RENESAS_RZ_A1_CLKIN * 30U;
66-
} else {
67-
/* Clock Mode 1 */
68-
/* CLKIN is 48MHz */
69-
/* Divider 1 uses 1/4 ratio, PLL x32 is ON */
70-
freq = (CM1_RENESAS_RZ_A1_CLKIN * 32U) / 4U;
71-
}
55+
freq = RENESAS_RZ_A1_SYS_CLK;
7256

7357
/* Get CPG.FRQCR[IFC] bits */
7458
ifc = (CPG.FRQCR >> 8U) & 0x03U;
@@ -77,12 +61,11 @@ void SystemCoreClockUpdate (void)
7761
if (ifc == 0x03U) {
7862
/* Division ratio is 1/3 */
7963
freq = (freq / 3U);
80-
}
81-
else {
82-
if (ifc == 0x01U) {
83-
/* Division ratio is 2/3 */
84-
freq = (freq * 2U) / 3U;
85-
}
64+
} else if (ifc == 0x01U) {
65+
/* Division ratio is 2/3 */
66+
freq = (freq * 2U) / 3U;
67+
} else {
68+
/* do nothing */
8669
}
8770

8871
SystemCoreClock = freq;

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_GR_LYCHEE/mbed_drv_cfg.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
#define RENESAS_RZ_A1_P0_CLK CM1_RENESAS_RZ_A1_P0_CLK
3636

37+
/* Clock Mode 1 */
38+
/* CLKIN is 48MHz */
39+
/* Divider 1 uses 1/4 ratio, PLL x32 is ON */
40+
#define RENESAS_RZ_A1_SYS_CLK ((CM1_RENESAS_RZ_A1_CLKIN * 32U) / 4U)
41+
3742
#define LP_TICKER_MTU2_CH 2
3843

3944
/* flash (W25Q64JV) */

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_RZ_A1H/device/os_tick_ostm.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
2626

2727
#include "os_tick.h"
2828
#include "irq_ctrl.h"
29-
30-
#include <MBRZA1H.h>
31-
32-
#include <cmsis.h>
29+
#include "cmsis.h"
30+
#include "mbed_drv_cfg.h"
3331

3432

3533
// Define OS TImer interrupt priority
@@ -62,15 +60,15 @@ int32_t OS_Tick_Setup (uint32_t freq, IRQHandler_t handler)
6260
// Get CPG.FRQCR[IFC] bits
6361
clock = (CPG.FRQCR >> 8) & 0x03;
6462

65-
// Determine Divider 2 output clock by using SystemCoreClock
63+
// Determine Divider 2 output clock by using RENESAS_RZ_A1_P0_CLK
6664
if (clock == 0x03U) {
67-
clock = (SystemCoreClock * 3U);
65+
clock = (RENESAS_RZ_A1_P0_CLK * 3U);
6866
}
6967
else if (clock == 0x01U) {
70-
clock = (SystemCoreClock * 3U)/2U;
68+
clock = (RENESAS_RZ_A1_P0_CLK * 3U)/2U;
7169
}
7270
else {
73-
clock = SystemCoreClock;
71+
clock = RENESAS_RZ_A1_P0_CLK;
7472
}
7573

7674
// Determine tick frequency

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_RZ_A1H/device/system_RZ_A1H.c

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@
2626
* limitations under the License.
2727
*/
2828

29-
#include <RZ_A1H.h>
29+
#include "RZ_A1H.h"
3030
#include "RZ_A1_Init.h"
3131
#include "irq_ctrl.h"
32-
33-
#define CS2_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFD040)
34-
#define CS3_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFE040)
35-
#define GPIO_PORT0_BOOTMODE_BITMASK (0x000fu)
32+
#include "mbed_drv_cfg.h"
3633

3734
/*
3835
Port 0 (P0) MD pin assignment
@@ -45,30 +42,17 @@
4542
/*----------------------------------------------------------------------------
4643
System Core Clock Variable
4744
*----------------------------------------------------------------------------*/
48-
uint32_t SystemCoreClock = CM0_RENESAS_RZ_A1_P0_CLK;
45+
uint32_t SystemCoreClock = RENESAS_RZ_A1_SYS_CLK;
4946

5047
/*----------------------------------------------------------------------------
5148
System Core Clock update function
5249
*----------------------------------------------------------------------------*/
5350
void SystemCoreClockUpdate (void)
5451
{
5552
uint32_t freq;
56-
uint16_t mode;
5753
uint16_t ifc;
5854

59-
mode = (GPIO.PPR0 >> 2U) & 0x01U;
60-
61-
if (mode == 0) {
62-
/* Clock Mode 0 */
63-
/* CLKIN is between 10MHz and 13.33MHz */
64-
/* Divider 1 uses 1/1 ratio, PLL x30 is ON */
65-
freq = CM0_RENESAS_RZ_A1_CLKIN * 30U;
66-
} else {
67-
/* Clock Mode 1 */
68-
/* CLKIN is 48MHz */
69-
/* Divider 1 uses 1/4 ratio, PLL x32 is ON */
70-
freq = (CM1_RENESAS_RZ_A1_CLKIN * 32U) / 4U;
71-
}
55+
freq = RENESAS_RZ_A1_SYS_CLK;
7256

7357
/* Get CPG.FRQCR[IFC] bits */
7458
ifc = (CPG.FRQCR >> 8U) & 0x03U;
@@ -77,12 +61,11 @@ void SystemCoreClockUpdate (void)
7761
if (ifc == 0x03U) {
7862
/* Division ratio is 1/3 */
7963
freq = (freq / 3U);
80-
}
81-
else {
82-
if (ifc == 0x01U) {
83-
/* Division ratio is 2/3 */
84-
freq = (freq * 2U) / 3U;
85-
}
64+
} else if (ifc == 0x01U) {
65+
/* Division ratio is 2/3 */
66+
freq = (freq * 2U) / 3U;
67+
} else {
68+
/* do nothing */
8669
}
8770

8871
SystemCoreClock = freq;

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_RZ_A1H/mbed_drv_cfg.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
#define RENESAS_RZ_A1_P0_CLK CM0_RENESAS_RZ_A1_P0_CLK
3636

37+
/* Clock Mode 0 */
38+
/* CLKIN is between 10MHz and 13.33MHz */
39+
/* Divider 1 uses 1/1 ratio, PLL x30 is ON */
40+
#define RENESAS_RZ_A1_SYS_CLK (CM0_RENESAS_RZ_A1_CLKIN * 30U)
41+
3742
#define LP_TICKER_MTU2_CH 3
3843

3944
/* flash (MX25L6433FM2I) */

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_VK_RZ_A1H/device/os_tick_ostm.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
2626

2727
#include "os_tick.h"
2828
#include "irq_ctrl.h"
29-
30-
#include <VKRZA1H.h>
31-
32-
#include <cmsis.h>
29+
#include "cmsis.h"
30+
#include "mbed_drv_cfg.h"
3331

3432

3533
// Define OS TImer interrupt priority
@@ -62,15 +60,15 @@ int32_t OS_Tick_Setup (uint32_t freq, IRQHandler_t handler)
6260
// Get CPG.FRQCR[IFC] bits
6361
clock = (CPG.FRQCR >> 8) & 0x03;
6462

65-
// Determine Divider 2 output clock by using SystemCoreClock
63+
// Determine Divider 2 output clock by using RENESAS_RZ_A1_P0_CLK
6664
if (clock == 0x03U) {
67-
clock = (SystemCoreClock * 3U);
65+
clock = (RENESAS_RZ_A1_P0_CLK * 3U);
6866
}
6967
else if (clock == 0x01U) {
70-
clock = (SystemCoreClock * 3U)/2U;
68+
clock = (RENESAS_RZ_A1_P0_CLK * 3U)/2U;
7169
}
7270
else {
73-
clock = SystemCoreClock;
71+
clock = RENESAS_RZ_A1_P0_CLK;
7472
}
7573

7674
// Determine tick frequency

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_VK_RZ_A1H/device/system_VK_RZ_A1H.c

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@
2626
* limitations under the License.
2727
*/
2828

29-
#include <VK_RZ_A1H.h>
29+
#include "VK_RZ_A1H.h"
3030
#include "RZ_A1_Init.h"
3131
#include "irq_ctrl.h"
32-
33-
#define CS2_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFD040)
34-
#define CS3_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFE040)
35-
#define GPIO_PORT0_BOOTMODE_BITMASK (0x000fu)
32+
#include "mbed_drv_cfg.h"
3633

3734
/*
3835
Port 0 (P0) MD pin assignment
@@ -45,48 +42,34 @@
4542
/*----------------------------------------------------------------------------
4643
System Core Clock Variable
4744
*----------------------------------------------------------------------------*/
48-
uint32_t SystemCoreClock = CM0_RENESAS_RZ_A1_P0_CLK;
45+
uint32_t SystemCoreClock = RENESAS_RZ_A1_SYS_CLK;
4946

5047
/*----------------------------------------------------------------------------
5148
System Core Clock update function
5249
*----------------------------------------------------------------------------*/
5350
void SystemCoreClockUpdate (void)
54-
{
51+
{
5552
uint32_t freq;
56-
uint16_t mode;
5753
uint16_t ifc;
5854

59-
mode = (GPIO.PPR0 >> 2U) & 0x01U;
55+
freq = RENESAS_RZ_A1_SYS_CLK;
6056

61-
if (mode == 0) {
62-
/* Clock Mode 0 */
63-
/* CLKIN is between 10MHz and 13.33MHz */
64-
/* Divider 1 uses 1/1 ratio, PLL x30 is ON */
65-
freq = CM0_RENESAS_RZ_A1_CLKIN * 30U;
66-
} else {
67-
/* Clock Mode 1 */
68-
/* CLKIN is 48MHz */
69-
/* Divider 1 uses 1/4 ratio, PLL x32 is ON */
70-
freq = (CM1_RENESAS_RZ_A1_CLKIN * 32U) / 4U;
71-
}
72-
7357
/* Get CPG.FRQCR[IFC] bits */
7458
ifc = (CPG.FRQCR >> 8U) & 0x03U;
75-
59+
7660
/* Determine Divider 2 output clock */
7761
if (ifc == 0x03U) {
7862
/* Division ratio is 1/3 */
7963
freq = (freq / 3U);
64+
} else if (ifc == 0x01U) {
65+
/* Division ratio is 2/3 */
66+
freq = (freq * 2U) / 3U;
67+
} else {
68+
/* do nothing */
8069
}
81-
else {
82-
if (ifc == 0x01U) {
83-
/* Division ratio is 2/3 */
84-
freq = (freq * 2U) / 3U;
85-
}
86-
}
8770

8871
SystemCoreClock = freq;
89-
}
72+
}
9073

9174
/*----------------------------------------------------------------------------
9275
IRQ Handler Register/Unregister

targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_VK_RZ_A1H/mbed_drv_cfg.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@
3434

3535
#define RENESAS_RZ_A1_P0_CLK CM0_RENESAS_RZ_A1_P0_CLK
3636

37+
/* Clock Mode 0 */
38+
/* CLKIN is between 10MHz and 13.33MHz */
39+
/* Divider 1 uses 1/1 ratio, PLL x30 is ON */
40+
#define RENESAS_RZ_A1_SYS_CLK (CM0_RENESAS_RZ_A1_CLKIN * 30U)
41+
3742
#endif

0 commit comments

Comments
 (0)