-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpudrv.c
More file actions
81 lines (66 loc) · 1.65 KB
/
cpudrv.c
File metadata and controls
81 lines (66 loc) · 1.65 KB
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
76
77
78
79
80
81
/*
* 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)
{
uint32_t dataL;
PowerOnTmu0();
*((volatile uint8_t*)OSTM0CTL) = 0x00U; /* Interval Timer Mode */
*((volatile uint32_t*)OSTM0CMP) = 100000U * tenmSec; /* (100MHz)*100000=1000us */
*((volatile uint8_t*)OSTM0TS) |= BIT0; /* TMU0 Start */
while(1)
{
dataL = *((volatile uint8_t*)OSTM0CNT);
if (dataL == 0x0U)
{
break;
}
}
*((volatile uint8_t*)OSTM0TT) |= BIT0; /* TMU0 Stop */
}
void StartTMU0usec(uint32_t tenuSec)
{
uint32_t dataL;
PowerOnTmu0();
*((volatile uint8_t*)OSTM0CTL) = 0x00U; /* Interval Timer Mode */
*((volatile uint32_t*)OSTM0CMP) = 100U * tenuSec; /* (100MHz)*100=1.0us */
*((volatile uint8_t*)OSTM0TS) |= BIT0; /* TMU0 Start */
while(1)
{
dataL = *((volatile uint8_t*)OSTM0CNT);
if (dataL == 0x0U)
{
break;
}
}
*((volatile uint8_t*)OSTM0TT) |= BIT0; /* 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 */
}