Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
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
White Rabbit Switch - Software
Commits
105052f6
Commit
105052f6
authored
Oct 16, 2014
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/libwr: remove warnings
parent
33d70757
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
25 additions
and
28 deletions
+25
-28
switch_hw.h
userspace/include/switch_hw.h
+1
-0
util.h
userspace/include/util.h
+1
-0
fan.c
userspace/libwr/fan.c
+3
-3
i2c.c
userspace/libwr/i2c.c
+2
-1
i2c_bitbang.c
userspace/libwr/i2c_bitbang.c
+2
-1
i2c_io.c
userspace/libwr/i2c_io.c
+0
-2
i2c_io.h
userspace/libwr/i2c_io.h
+0
-2
i2c_sfp.c
userspace/libwr/i2c_sfp.c
+7
-7
init.c
userspace/libwr/init.c
+1
-0
libshw_i2c.c
userspace/libwr/libshw_i2c.c
+1
-3
pio.c
userspace/libwr/pio.c
+1
-0
pps_gen.c
userspace/libwr/pps_gen.c
+2
-2
shw_io.c
userspace/libwr/shw_io.c
+4
-7
No files found.
userspace/include/switch_hw.h
View file @
105052f6
...
...
@@ -14,6 +14,7 @@
/* System reference clock rate (in Hertz). Update together with REF_CLOCK_PERIOD_PS */
#define REF_CLOCK_RATE_HZ 62500000
/* return 0 on success */
int
shw_init
(
void
);
int
shw_fpga_mmap_init
(
void
);
#endif
userspace/include/util.h
View file @
105052f6
...
...
@@ -10,5 +10,6 @@ void shw_udelay(uint32_t microseconds);
void
*
shw_malloc
(
size_t
nbytes
);
void
shw_free
(
void
*
ptr
);
const
char
*
shw_2binary
(
uint8_t
x
);
uint64_t
shw_get_tics
();
#endif
userspace/libwr/fan.c
View file @
105052f6
...
...
@@ -32,11 +32,12 @@
#include <at91_softpwm.h>
#include "i2c.h"
#include "i2c_io.h"
#include "i2c_fpga_reg.h"
#include "fpga_io.h"
#include "shw_io.h"
#include "spwm-regs.h"
#include "util.h"
#define FAN_TEMP_SENSOR_ADDR 0x4c
...
...
@@ -204,13 +205,12 @@ int shw_init_i2c_sensors()
TRACE
(
TRACE_FATAL
,
"can't initialize temperature sensors I2C bus.
\n
"
);
return
-
1
;
}
return
0
;
}
int
shw_init_fans
()
{
uint8_t
dev_map
[
128
];
uint32_t
val
=
0
;
int
detect
,
i
;
//Set the type of PWM
if
(
shw_get_hw_ver
()
<
330
)
is_cpu_pwn
=
1
;
...
...
userspace/libwr/i2c.c
View file @
105052f6
...
...
@@ -6,7 +6,8 @@
#include "i2c_bitbang.h"
#include "i2c_fpga_reg.h"
#include <trace.h>
#include "trace.h"
#include "util.h"
int
i2c_init_bus
(
struct
i2c_bus
*
bus
)
{
...
...
userspace/libwr/i2c_bitbang.c
View file @
105052f6
...
...
@@ -52,6 +52,7 @@ static void mi2c_start(struct i2c_bitbang* bus)
mi2c_pin_out
(
bus
->
scl
,
0
);
}
/* not used right now
static void mi2c_restart(struct i2c_bitbang* bus)
{
mi2c_pin_out(bus->sda, 1);
...
...
@@ -59,7 +60,7 @@ static void mi2c_restart(struct i2c_bitbang* bus)
mi2c_pin_out(bus->sda, 0);
mi2c_pin_out(bus->scl, 0);
}
*/
static
void
mi2c_stop
(
struct
i2c_bitbang
*
bus
)
{
...
...
userspace/libwr/i2c_io.c
View file @
105052f6
...
...
@@ -69,8 +69,6 @@ struct i2c_bus i2c_io_bus = {
int
shw_i2c_io_init
(
void
)
{
int
i
;
TRACE
(
TRACE_INFO
,
"Initializing IO I2C bus...%s"
,
__TIME__
);
if
(
i2c_init_bus
(
&
i2c_io_bus
)
<
0
)
{
TRACE
(
TRACE_ERROR
,
"init failed: %s"
,
i2c_io_bus
.
name
);
...
...
userspace/libwr/i2c_io.h
View file @
105052f6
...
...
@@ -22,8 +22,6 @@ extern struct i2c_bus i2c_io_bus;
int
shw_i2c_io_init
(
void
);
int
shw_i2c_io_scan
(
uint8_t
*
dev_map
);
uint8_t
shw_i2c_read
(
const
*
i2c_bus
,
uint8_t
addr
);
uint8_t
shw_i2c_write
(
const
*
i2c_bus
,
uint8_t
addr
,
uint8_t
value
,
uint8_t
mask
);
int
shw_get_hw_ver
();
uint8_t
shw_get_fpga_type
();
...
...
userspace/libwr/i2c_sfp.c
View file @
105052f6
...
...
@@ -13,8 +13,9 @@
#include <lauxlib.h>
#include <lualib.h>
#include <pio.h>
#include <trace.h>
#include "pio.h"
#include "trace.h"
#include "util.h"
#include "i2c.h"
#include "i2c_sfp.h"
...
...
@@ -285,7 +286,7 @@ void shw_sfp_print_header(struct shw_sfp_header *head)
for
(
i
=
0
;
i
<
16
;
i
++
)
printf
(
"%c"
,
head
->
vendor_serial
[
i
]);
printf
(
"
\n
"
);
uint8_t
*
date
=
(
uint8_t
*
)
&
head
->
date_code
;
printf
(
"Date Code: "
);
for
(
i
=
0
;
i
<
8
;
i
++
)
printf
(
"%c"
,
head
->
date_code
[
i
]);
...
...
@@ -429,7 +430,6 @@ void shw_sfp_gpio_set(int num, uint8_t state)
struct
i2c_bus
*
bus
;
uint8_t
addr
=
0x20
;
uint8_t
send
[
2
];
uint8_t
out
=
0
;
uint8_t
curr
;
id
=
shw_sfp_id
(
num
);
...
...
@@ -568,11 +568,11 @@ int shw_sfp_read_db(char *filename)
lua_pop
(
L
,
1
);
continue
;
}
int
i
=
0
;
const
char
*
sfp_pn
=
0
;
const
char
*
sfp_vs
=
0
;
int
vals
[
2
];
double
alpha
;
int
vals
[
2
]
=
{
0
,
0
}
;
double
alpha
=
0
;
lua_pushnil
(
L
);
while
(
lua_next
(
L
,
-
2
))
{
const
char
*
key
=
lua_tostring
(
L
,
-
2
);
...
...
userspace/libwr/init.c
View file @
105052f6
...
...
@@ -31,6 +31,7 @@ int shw_init()
assert_init
(
shw_init_fans
());
TRACE
(
TRACE_INFO
,
"HW initialization done!"
);
return
0
;
}
int
shw_exit_fatal
()
...
...
userspace/libwr/libshw_i2c.c
View file @
105052f6
...
...
@@ -4,9 +4,7 @@ int wrswhw_pca9554_configure(struct i2c_bus* bus, uint32_t address,uint8_t value
{
//config initial port dir
uint8_t
config_outputs
[
2
]
=
{
PCA9554_CMD_DIR_REG
,
value
};
int
result
=
i2c_transfer
(
bus
,
address
,
sizeof
(
config_outputs
),
0
,
config_outputs
);
if
(
result
<
0
)
return
result
;
return
i2c_transfer
(
bus
,
address
,
sizeof
(
config_outputs
),
0
,
config_outputs
);
}
...
...
userspace/libwr/pio.c
View file @
105052f6
...
...
@@ -13,6 +13,7 @@
#include "pio.h"
#include "trace.h"
#include "shw_io.h"
#include "util.h"
volatile
uint8_t
*
_pio_base
[
4
][
NUM_PIO_BANKS
+
1
];
volatile
uint8_t
*
_sys_base
;
...
...
userspace/libwr/pps_gen.c
View file @
105052f6
...
...
@@ -3,6 +3,7 @@
/* Warning: references to "UTC" in the registers DO NOT MEAN actual UTC time, it's just a plain second counter
It doesn't care about leap seconds. */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
...
...
@@ -40,13 +41,12 @@ int shw_pps_gen_init()
ppsg_write
(
CR
,
cr
|
PPSG_CR_CNT_SET
);
ppsg_write
(
CR
,
cr
);
ppsg_write
(
ESCR
,
0x6
);
/* enable PPS output */
return
0
;
}
/* Adjusts the nanosecond (refclk cycle) counter by atomically adding (how_much) cycles. */
int
shw_pps_gen_adjust
(
int
counter
,
int64_t
how_much
)
{
uint32_t
cr
;
TRACE
(
TRACE_INFO
,
"Adjust: counter = %s [%c%lld]"
,
counter
==
PPSG_ADJUST_SEC
?
"seconds"
:
"nanoseconds"
,
how_much
<
0
?
'-'
:
'+'
,
abs
(
how_much
));
...
...
userspace/libwr/shw_io.c
View file @
105052f6
...
...
@@ -70,7 +70,7 @@ const shw_io_t _all_shw_io[NUM_SHW_IO_ID];
int
shw_io_init
()
{
int
ret
,
ver
;
int
ver
;
//Remove const for writing
shw_io_t
*
all_shw_io
=
(
shw_io_t
*
)
_all_shw_io
;
...
...
@@ -148,6 +148,7 @@ const pio_pin_t* get_pio_pin(shw_io_id_t id)
const
shw_io_t
*
wrpin
=
get_shw_io
(
id
);
if
(
wrpin
&&
wrpin
->
type
==
SHW_CPU_PIO
)
return
(
wrpin
)
?
(
const
pio_pin_t
*
)
wrpin
->
ptr
:
0
;
return
NULL
;
}
const
shw_io_t
*
get_shw_io
(
shw_io_id_t
id
)
...
...
@@ -158,15 +159,13 @@ const shw_io_t* get_shw_io(shw_io_id_t id)
else
TRACE
(
TRACE_ERROR
,
"IO %d does not correspond to its ID %s"
,
id
,
_all_shw_io
[
id
].
name
);
}
else
TRACE
(
TRACE_ERROR
,
"IO %d does not exist"
,
id
);
return
0
;
return
NULL
;
}
uint32_t
shw_io_read
(
shw_io_id_t
id
)
{
uint32_t
ret
;
int32_t
i32data
;
uint8_t
u8data
[
2
];
const
shw_io_t
*
io
=&
_all_shw_io
[
id
];
const
shw_io_bus_t
*
iobus
;
...
...
@@ -189,14 +188,12 @@ uint32_t shw_io_read(shw_io_id_t id)
TRACE
(
TRACE_ERROR
,
"Unknow type %d for io #%d"
,
io
->
type
,
id
);
break
;
}
}
return
ret
;
return
0
;
}
int
shw_io_write
(
shw_io_id_t
id
,
uint32_t
value
)
{
int
ret
=-
1
;
int32_t
i32data
;
uint8_t
u8data
[
2
];
const
shw_io_t
*
io
=&
_all_shw_io
[
id
];
const
shw_io_bus_t
*
iobus
;
...
...
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