Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
TDC core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
TDC core
Commits
8c58b1a1
Commit
8c58b1a1
authored
Oct 30, 2011
by
Sebastien Bourdeauducq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demo: temperature sensor working
parent
8fd5c642
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
10 deletions
+79
-10
system.v
demo/boards/spec/rtl/system.v
+1
-1
Makefile
demo/software/demo/Makefile
+4
-4
linker.ld
demo/software/demo/linker.ld
+1
-1
temperature.c
demo/software/demo/temperature.c
+72
-4
temperature.h
demo/software/demo/temperature.h
+1
-0
No files found.
demo/boards/spec/rtl/system.v
View file @
8c58b1a1
...
@@ -368,7 +368,7 @@ lm32_top cpu(
...
@@ -368,7 +368,7 @@ lm32_top cpu(
// BRAM/SRAM
// BRAM/SRAM
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
bram
#(
bram
#(
.
adr_width
(
1
4
)
,
.
adr_width
(
1
5
)
,
.
init0
(
"../../../software/demo/demo.h0"
)
,
.
init0
(
"../../../software/demo/demo.h0"
)
,
.
init1
(
"../../../software/demo/demo.h1"
)
,
.
init1
(
"../../../software/demo/demo.h1"
)
,
.
init2
(
"../../../software/demo/demo.h2"
)
,
.
init2
(
"../../../software/demo/demo.h2"
)
,
...
...
demo/software/demo/Makefile
View file @
8c58b1a1
...
@@ -7,16 +7,16 @@ SEGMENTS=-j .text -j .data -j .rodata
...
@@ -7,16 +7,16 @@ SEGMENTS=-j .text -j .data -j .rodata
all
:
demo.bin demo.h0 demo.h1 demo.h2 demo.h3
all
:
demo.bin demo.h0 demo.h1 demo.h2 demo.h3
demo.h0
:
demo.bin
demo.h0
:
demo.bin
$(MMDIR)
/tools/bin2hex
$<
$@
4096
4
$(MMDIR)
/tools/bin2hex
$<
$@
8192
4
demo.h1
:
demo.bin
demo.h1
:
demo.bin
$(MMDIR)
/tools/bin2hex
$<
$@
4096
3
$(MMDIR)
/tools/bin2hex
$<
$@
8192
3
demo.h2
:
demo.bin
demo.h2
:
demo.bin
$(MMDIR)
/tools/bin2hex
$<
$@
4096
2
$(MMDIR)
/tools/bin2hex
$<
$@
8192
2
demo.h3
:
demo.bin
demo.h3
:
demo.bin
$(MMDIR)
/tools/bin2hex
$<
$@
4096
1
$(MMDIR)
/tools/bin2hex
$<
$@
8192
1
%.bin
:
%.elf
%.bin
:
%.elf
$(OBJCOPY)
$(SEGMENTS)
-O
binary
$<
$@
$(OBJCOPY)
$(SEGMENTS)
-O
binary
$<
$@
...
...
demo/software/demo/linker.ld
View file @
8c58b1a1
...
@@ -4,7 +4,7 @@ ENTRY(_start)
...
@@ -4,7 +4,7 @@ ENTRY(_start)
__DYNAMIC = 0;
__DYNAMIC = 0;
MEMORY {
MEMORY {
bram : ORIGIN = 0x00000000, LENGTH = 0x
4
000
bram : ORIGIN = 0x00000000, LENGTH = 0x
8
000
sram : ORIGIN = 0x40000000, LENGTH = 0x4000
sram : ORIGIN = 0x40000000, LENGTH = 0x4000
}
}
...
...
demo/software/demo/temperature.c
View file @
8c58b1a1
...
@@ -46,10 +46,78 @@ static int reset_1w()
...
@@ -46,10 +46,78 @@ static int reset_1w()
return
ok
;
return
ok
;
}
}
static
void
txbyte_1w
(
unsigned
char
b
)
{
int
i
;
for
(
i
=
0
;
i
<
8
;
i
++
)
{
if
(
b
&
(
1
<<
i
))
{
CSR_GPIO_OUT
|=
GPIO_1W_DRIVELOW
;
udelay
(
10
);
CSR_GPIO_OUT
&=
~
GPIO_1W_DRIVELOW
;
udelay
(
90
);
}
else
{
CSR_GPIO_OUT
|=
GPIO_1W_DRIVELOW
;
udelay
(
65
);
CSR_GPIO_OUT
&=
~
GPIO_1W_DRIVELOW
;
udelay
(
35
);
}
}
}
static
int
rxbit_1w
()
{
int
r
;
CSR_GPIO_OUT
|=
GPIO_1W_DRIVELOW
;
udelay
(
5
);
CSR_GPIO_OUT
&=
~
GPIO_1W_DRIVELOW
;
udelay
(
5
);
r
=
CSR_GPIO_IN
&
GPIO_1W
;
udelay
(
90
);
return
r
;
}
static
unsigned
char
rxbyte_1w
()
{
unsigned
char
b
;
int
i
;
b
=
0
;
for
(
i
=
0
;
i
<
8
;
i
++
)
{
if
(
rxbit_1w
())
b
|=
(
1
<<
i
);
}
return
b
;
}
int
gettemp
()
{
unsigned
char
sp
[
9
];
int
i
;
if
(
!
reset_1w
())
{
printf
(
"1W reset failed (1)
\n
"
);
return
-
1000
;
}
txbyte_1w
(
0xcc
);
/* skip ROM */
txbyte_1w
(
0x44
);
/* convert temperature */
while
(
!
rxbyte_1w
());
/* wait for end of conversion */
if
(
!
reset_1w
())
{
printf
(
"1W reset failed (2)
\n
"
);
return
-
1000
;
}
txbyte_1w
(
0xcc
);
/* skip ROM */
txbyte_1w
(
0xbe
);
/* read scratchpad */
for
(
i
=
0
;
i
<
9
;
i
++
)
sp
[
i
]
=
rxbyte_1w
();
return
(((
short
)
sp
[
1
])
<<
8
)
|
((
short
)
sp
[
0
]);
}
void
temp
()
void
temp
()
{
{
i
f
(
reset_1w
())
i
nt
t
;
printf
(
"1W reset OK
\n
"
);
else
t
=
gettemp
();
printf
(
"1W reset failed
\n
"
);
printf
(
"%d.%04dC
\n
"
,
t
/
16
,
(
t
%
16
)
*
625
);
}
}
demo/software/demo/temperature.h
View file @
8c58b1a1
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#ifndef __TEMPERATURE_H
#ifndef __TEMPERATURE_H
#define __TEMPERATURE_H
#define __TEMPERATURE_H
int
gettemp
();
void
temp
();
void
temp
();
#endif
/* __TEMPERATURE_H */
#endif
/* __TEMPERATURE_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment