Skip to content

Commit 82c8684

Browse files
committed
Refactoring system clock driver
1 parent 1505b53 commit 82c8684

File tree

6 files changed

+27
-51
lines changed

6 files changed

+27
-51
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
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"
3330
#include "mbed_drv_cfg.h"
3431

3532

@@ -145,7 +142,8 @@ void OS_Tick_Enable (void)
145142
}
146143

147144
/// Disable OS Tick.
148-
void OS_Tick_Disable (void) {
145+
void OS_Tick_Disable (void)
146+
{
149147

150148
// Stop the OSTM counter
151149
OSTM.OSTMnTT = 0x01U;
@@ -157,7 +155,7 @@ void OS_Tick_Disable (void) {
157155
}
158156

159157
// Acknowledge OS Tick IRQ.
160-
void OS_Tick_AcknowledgeIRQ (void)
158+
void OS_Tick_AcknowledgeIRQ (void)
161159
{
162160
IRQ_ClearPending (OSTM_IRQn);
163161
}

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@
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"
3232
#include "mbed_drv_cfg.h"
3333

34-
35-
#define CS2_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFD040)
36-
#define CS3_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFE040)
37-
#define GPIO_PORT0_BOOTMODE_BITMASK (0x000fu)
38-
3934
/*
4035
Port 0 (P0) MD pin assignment
4136
P0_0: MD_BOOT0
@@ -66,12 +61,11 @@ void SystemCoreClockUpdate (void)
6661
if (ifc == 0x03U) {
6762
/* Division ratio is 1/3 */
6863
freq = (freq / 3U);
69-
}
70-
else {
71-
if (ifc == 0x01U) {
72-
/* Division ratio is 2/3 */
73-
freq = (freq * 2U) / 3U;
74-
}
64+
} else if (ifc == 0x01U) {
65+
/* Division ratio is 2/3 */
66+
freq = (freq * 2U) / 3U;
67+
} else {
68+
/* do nothing */
7569
}
7670

7771
SystemCoreClock = freq;

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
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"
3330
#include "mbed_drv_cfg.h"
3431

3532

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,11 @@
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"
3232
#include "mbed_drv_cfg.h"
3333

34-
#define CS2_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFD040)
35-
#define CS3_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFE040)
36-
#define GPIO_PORT0_BOOTMODE_BITMASK (0x000fu)
37-
3834
/*
3935
Port 0 (P0) MD pin assignment
4036
P0_0: MD_BOOT0
@@ -65,12 +61,11 @@ void SystemCoreClockUpdate (void)
6561
if (ifc == 0x03U) {
6662
/* Division ratio is 1/3 */
6763
freq = (freq / 3U);
68-
}
69-
else {
70-
if (ifc == 0x01U) {
71-
/* Division ratio is 2/3 */
72-
freq = (freq * 2U) / 3U;
73-
}
64+
} else if (ifc == 0x01U) {
65+
/* Division ratio is 2/3 */
66+
freq = (freq * 2U) / 3U;
67+
} else {
68+
/* do nothing */
7469
}
7570

7671
SystemCoreClock = freq;

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
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"
3330
#include "mbed_drv_cfg.h"
3431

3532

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,11 @@
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"
3232
#include "mbed_drv_cfg.h"
3333

34-
#define CS2_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFD040)
35-
#define CS3_SDRAM_MODE_16BIT_CAS2_BR_BW (*(volatile uint16_t*)0x3FFFE040)
36-
#define GPIO_PORT0_BOOTMODE_BITMASK (0x000fu)
37-
3834
/*
3935
Port 0 (P0) MD pin assignment
4036
P0_0: MD_BOOT0
@@ -52,29 +48,28 @@ uint32_t SystemCoreClock = RENESAS_RZ_A1_SYS_CLK;
5248
System Core Clock update function
5349
*----------------------------------------------------------------------------*/
5450
void SystemCoreClockUpdate (void)
55-
{
51+
{
5652
uint32_t freq;
5753
uint16_t ifc;
5854

5955
freq = RENESAS_RZ_A1_SYS_CLK;
6056

6157
/* Get CPG.FRQCR[IFC] bits */
6258
ifc = (CPG.FRQCR >> 8U) & 0x03U;
63-
59+
6460
/* Determine Divider 2 output clock */
6561
if (ifc == 0x03U) {
6662
/* Division ratio is 1/3 */
6763
freq = (freq / 3U);
64+
} else if (ifc == 0x01U) {
65+
/* Division ratio is 2/3 */
66+
freq = (freq * 2U) / 3U;
67+
} else {
68+
/* do nothing */
6869
}
69-
else {
70-
if (ifc == 0x01U) {
71-
/* Division ratio is 2/3 */
72-
freq = (freq * 2U) / 3U;
73-
}
74-
}
7570

7671
SystemCoreClock = freq;
77-
}
72+
}
7873

7974
/*----------------------------------------------------------------------------
8075
IRQ Handler Register/Unregister

0 commit comments

Comments
 (0)