Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RF24
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
RF24
Commits
4c52feb2
Commit
4c52feb2
authored
Apr 01, 2016
by
mz-fuzzy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spidev fix: don't close spidev if not open before
Signed-off-by:
mz-fuzzy
<
mzfuzzy800@gmail.com
>
parent
406265e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
RF24.cpp
RF24.cpp
+0
-2
utility/SPIDEV/spi.cpp
utility/SPIDEV/spi.cpp
+12
-10
No files found.
RF24.cpp
View file @
4c52feb2
...
...
@@ -573,8 +573,6 @@ bool RF24::begin(void)
#if defined (RF24_LINUX)
SPI
();
#if defined (MRAA)
GPIO
();
gpio
.
begin
(
ce_pin
,
csn_pin
);
...
...
utility/SPIDEV/spi.cpp
View file @
4c52feb2
...
...
@@ -13,8 +13,7 @@
#include <pthread.h>
static
pthread_mutex_t
spiMutex
;
SPI
::
SPI
()
{
SPI
::
SPI
()
:
fd
(
-
1
)
{
}
void
SPI
::
begin
(
int
busNo
){
...
...
@@ -38,14 +37,16 @@ void SPI::init()
{
int
ret
;
if
(
!
(
this
->
fd
>
0
)){
if
(
this
->
fd
<
0
)
// check whether spi is already open
{
this
->
fd
=
open
(
this
->
device
.
c_str
(),
O_RDWR
);
}
if
(
this
->
fd
<
0
)
{
perror
(
"can't open device"
);
abort
();
}
if
(
this
->
fd
<
0
)
{
perror
(
"can't open device"
);
abort
();
}
}
/*
* spi mode
...
...
@@ -193,6 +194,7 @@ void SPI::transfern(char* buf, uint32_t len)
SPI
::~
SPI
()
{
close
(
this
->
fd
);
if
(
!
(
this
->
fd
<
0
))
close
(
this
->
fd
);
}
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