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
8fd5c642
Commit
8fd5c642
authored
Oct 29, 2011
by
Sebastien Bourdeauducq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demo: 1wire GPIO access + reset
parent
b1c504ad
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
12 deletions
+97
-12
system.v
demo/boards/spec/rtl/system.v
+7
-4
common.ucf
demo/boards/spec/synthesis/common.ucf
+1
-2
Makefile
demo/software/demo/Makefile
+1
-1
main.c
demo/software/demo/main.c
+2
-0
temperature.c
demo/software/demo/temperature.c
+55
-0
temperature.h
demo/software/demo/temperature.h
+24
-0
gpio.h
demo/software/include/hw/gpio.h
+7
-5
No files found.
demo/boards/spec/rtl/system.v
View file @
8fd5c642
...
...
@@ -30,6 +30,7 @@ module system(
// GPIO
input
btn
,
output
[
3
:
0
]
led
,
inout
onewire
,
// TDC
input
tdc_signal
...
...
@@ -428,10 +429,11 @@ uart #(
//---------------------------------------------------------------------------
// System Controller
//---------------------------------------------------------------------------
wire
onewire_drivelow
;
sysctl
#(
.
csr_addr
(
4'h1
)
,
.
ninputs
(
1
)
,
.
noutputs
(
4
)
,
.
ninputs
(
2
)
,
.
noutputs
(
5
)
,
.
systemid
(
32'h53504543
)
/* SPEC */
)
sysctl
(
.
sys_clk
(
sys_clk
)
,
...
...
@@ -446,11 +448,12 @@ sysctl #(
.
csr_di
(
csr_dw
)
,
.
csr_do
(
csr_dr_sysctl
)
,
.
gpio_inputs
(
btn
)
,
.
gpio_outputs
(
led
)
,
.
gpio_inputs
(
{
onewire
,
btn
}
)
,
.
gpio_outputs
(
{
onewire_drivelow
,
led
}
)
,
.
hard_reset
(
hard_reset
)
)
;
assign
onewire
=
onewire_drivelow
?
1'b0
:
1'bz
;
//---------------------------------------------------------------------------
// TDC
...
...
demo/boards/spec/synthesis/common.ucf
View file @
8fd5c642
...
...
@@ -19,8 +19,7 @@ NET "led[0]" LOC = G19 | IOSTANDARD = "LVCMOS18"; # AUX LEDs
NET "led[1]" LOC = F20 | IOSTANDARD = "LVCMOS18";
NET "led[2]" LOC = F18 | IOSTANDARD = "LVCMOS18";
NET "led[3]" LOC = C20 | IOSTANDARD = "LVCMOS18";
# TODO: temperature probe
NET "onewire" LOC = D4 | IOSTANDARD = "LVCMOS25";
# ==== TDC inputs ====
# FIXME
...
...
demo/software/demo/Makefile
View file @
8fd5c642
MMDIR
=
../..
include
$(MMDIR)/software/include.mak
OBJECTS
=
crt0.o main.o tdc.o
OBJECTS
=
crt0.o main.o tdc.o
temperature.o
SEGMENTS
=
-j
.text
-j
.data
-j
.rodata
all
:
demo.bin demo.h0 demo.h1 demo.h2 demo.h3
...
...
demo/software/demo/main.c
View file @
8fd5c642
...
...
@@ -27,6 +27,7 @@
#include <hw/uart.h>
#include "tdc.h"
#include "temperature.h"
/* General address space functions */
...
...
@@ -222,6 +223,7 @@ static void do_command(char *c)
else
if
(
strcmp
(
token
,
"rofreq"
)
==
0
)
rofreq
();
else
if
(
strcmp
(
token
,
"calinfo"
)
==
0
)
calinfo
();
else
if
(
strcmp
(
token
,
"mraw"
)
==
0
)
mraw
();
else
if
(
strcmp
(
token
,
"temp"
)
==
0
)
temp
();
else
if
(
strcmp
(
token
,
""
)
!=
0
)
printf
(
"Command not found
\n
"
);
...
...
demo/software/demo/temperature.c
0 → 100644
View file @
8fd5c642
/*
* 1-wire temperature sensor access
*
* Copyright (C) 2011 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <hw/sysctl.h>
#include <hw/gpio.h>
#include "temperature.h"
static
void
udelay
(
int
usec
)
{
int
limit
;
limit
=
usec
*
125
;
CSR_TIMER0_CONTROL
=
0
;
CSR_TIMER0_COUNTER
=
0
;
CSR_TIMER0_CONTROL
=
TIMER_ENABLE
;
while
(
CSR_TIMER0_COUNTER
<
limit
);
}
static
int
reset_1w
()
{
int
ok
;
CSR_GPIO_OUT
|=
GPIO_1W_DRIVELOW
;
udelay
(
500
);
CSR_GPIO_OUT
&=
~
GPIO_1W_DRIVELOW
;
udelay
(
65
);
ok
=
!
(
CSR_GPIO_IN
&
GPIO_1W
);
udelay
(
500
);
return
ok
;
}
void
temp
()
{
if
(
reset_1w
())
printf
(
"1W reset OK
\n
"
);
else
printf
(
"1W reset failed
\n
"
);
}
demo/software/demo/temperature.h
0 → 100644
View file @
8fd5c642
/*
* 1-wire temperature sensor access
*
* Copyright (C) 2011 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __TEMPERATURE_H
#define __TEMPERATURE_H
void
temp
();
#endif
/* __TEMPERATURE_H */
demo/software/include/hw/gpio.h
View file @
8fd5c642
...
...
@@ -20,12 +20,14 @@
#define __HW_GPIO_H
/* Inputs */
#define GPIO_PB2 (0x00000001)
#define GPIO_PB2 (0x00000001)
#define GPIO_1W (0x00000002)
/* Outputs */
#define GPIO_LD2 (0x00000001)
#define GPIO_LD3 (0x00000002)
#define GPIO_LD4 (0x00000004)
#define GPIO_LD5 (0x00000008)
#define GPIO_LD2 (0x00000001)
#define GPIO_LD3 (0x00000002)
#define GPIO_LD4 (0x00000004)
#define GPIO_LD5 (0x00000008)
#define GPIO_1W_DRIVELOW (0x00000010)
#endif
/* __HW_GPIO_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