-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpudrv.c
75 lines (64 loc) · 1.52 KB
/
cpudrv.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Copyright (c) 2015-2021, Renesas Electronics Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "common.h"
#include "bit.h"
#include "cpg_regs.h"
#include "ostm_regs.h"
#include "cpudrv.h"
void StartTMU0(uint32_t tenmSec)
{
volatile uint32_t dataL;
PowerOnTmu0();
*((volatile uint8_t*)OSTM0CTL)= 0x02U; /* Free Running Mode */
*((volatile uint8_t*)OSTM0TS) = 0x01U; /* TMU0 Start */
while(1)
{
dataL = *((volatile uint32_t*)OSTM0CNT);
if (dataL >= (100000U * tenmSec))
{
break;
}
}
*((volatile uint8_t*)OSTM0TT) = 0x01U; /* TMU0 Stop */
}
void StartTMU0usec(uint32_t tenuSec)
{
volatile uint32_t dataL;
PowerOnTmu0();
*((volatile uint8_t*)OSTM0CTL)= 0x02U; /* Free Running Mode */
*((volatile uint8_t*)OSTM0TS) = 0x01U; /* TMU0 Start */
while(1)
{
dataL = *((volatile uint32_t*)OSTM0CNT);
if (dataL >= (100U * tenuSec))
{
break;
}
}
*((volatile uint8_t*)OSTM0TT) = 0x01U; /* TMU0 Stop */
}
void udelay(uint32_t count_us)
{
StartTMU0usec(count_us);
}
void PowerOnTmu0(void)
{
uint32_t dataL;
dataL = *((volatile uint32_t*)CPG_CLKON_OSTM);
dataL |= 0x00010001U;
*((volatile uint32_t*)CPG_CLKON_OSTM) = dataL;
do
{
dataL = *((volatile uint32_t*)CPG_CLKMON_OSTM);
} while ((dataL & BIT0) == 0U); /* wait until bit0=1 */
dataL = *((volatile uint32_t*)CPG_RST_OSTM);
dataL |= 0x00010001U;
*((volatile uint32_t*)CPG_RST_OSTM) = dataL;
do
{
dataL = *((volatile uint32_t*)CPG_RSTMON_OSTM);
} while ((dataL & BIT0) == 1U); /* wait until bit0=1 */
}