Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
purr-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
YARAMALA SIVA SAI VARDHAN REDDY
purr-data
Commits
8fe19795
Commit
8fe19795
authored
11 years ago
by
Ivica Bukvic
Browse files
Options
Downloads
Patches
Plain Diff
removed stale file and updated tar_em_up.sh script to also build raspberry pi externals
parent
a9638e54
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
l2ork_addons/raspberry_pi/disis_spi/spi_original.c
+0
-224
0 additions, 224 deletions
l2ork_addons/raspberry_pi/disis_spi/spi_original.c
l2ork_addons/tar_em_up.sh
+22
-15
22 additions, 15 deletions
l2ork_addons/tar_em_up.sh
with
22 additions
and
239 deletions
l2ork_addons/raspberry_pi/disis_spi/spi_original.c
deleted
100644 → 0
+
0
−
224
View file @
a9638e54
/***********************************************************************
* This header file contains the mcp3008Spi class definition.
* Its main purpose is to communicate with the MCP3008 chip using
* the userspace spidev facility.
* The class contains four variables:
* mode -> defines the SPI mode used. In our case it is SPI_MODE_0.
* bitsPerWord -> defines the bit width of the data transmitted.
* This is normally 8. Experimentation with other values
* didn't work for me
* speed -> Bus speed or SPI clock frequency. According to
* https://projects.drogon.net/understanding-spi-on-the-raspberry-pi/
* It can be only 0.5, 1, 2, 4, 8, 16, 32 MHz.
* Will use 1MHz for now and test it further.
* spifd -> file descriptor for the SPI device
*
* The class contains two constructors that initialize the above
* variables and then open the appropriate spidev device using spiOpen().
* The class contains one destructor that automatically closes the spidev
* device when object is destroyed by calling spiClose().
* The spiWriteRead() function sends the data "data" of length "length"
* to the spidevice and at the same time receives data of the same length.
* Resulting data is stored in the "data" variable after the function call.
* ****************************************************************************/
#include
<unistd.h>
#include
<stdint.h>
#include
<fcntl.h>
#include
<sys/ioctl.h>
#include
<linux/spi/spidev.h>
#include
<stdio.h>
#include
<errno.h>
#include
<stdlib.h>
typedef
struct
_spi
{
unsigned
char
mode
;
unsigned
char
bitsPerWord
;
unsigned
int
speed
;
int
spifd
;
}
t_spi
;
t_spi
*
spi_new
(
const
char
*
devspi
,
unsigned
char
spiMode
,
unsigned
int
spiSpeed
,
unsigned
char
spibitsPerWord
);
int
spi_WriteRead
(
t_spi
*
spi
,
unsigned
char
*
data
,
int
length
);
int
spi_Open
(
t_spi
*
spi
,
const
char
*
devspi
);
int
spi_Close
(
t_spi
*
spi
);
//using namespace std;
/**********************************************************
* spiOpen() :function is called by the constructor.
* It is responsible for opening the spidev device
* "devspi" and then setting up the spidev interface.
* private member variables are used to configure spidev.
* They must be set appropriately by constructor before calling
* this function.
* *********************************************************/
int
spi_Open
(
t_spi
*
spi
,
const
char
*
devspi
){
int
statusVal
=
-
1
;
spi
->
spifd
=
open
(
devspi
,
O_RDWR
);
if
(
spi
->
spifd
<
0
)
{
perror
(
"could not open SPI device"
);
exit
(
1
);
}
statusVal
=
ioctl
(
spi
->
spifd
,
SPI_IOC_WR_MODE
,
&
(
spi
->
mode
));
if
(
statusVal
<
0
){
perror
(
"Could not set SPIMode (WR)...ioctl fail"
);
exit
(
1
);
}
statusVal
=
ioctl
(
spi
->
spifd
,
SPI_IOC_RD_MODE
,
&
(
spi
->
mode
));
if
(
statusVal
<
0
)
{
perror
(
"Could not set SPIMode (RD)...ioctl fail"
);
exit
(
1
);
}
statusVal
=
ioctl
(
spi
->
spifd
,
SPI_IOC_WR_BITS_PER_WORD
,
&
(
spi
->
bitsPerWord
));
if
(
statusVal
<
0
)
{
perror
(
"Could not set SPI bitsPerWord (WR)...ioctl fail"
);
exit
(
1
);
}
statusVal
=
ioctl
(
spi
->
spifd
,
SPI_IOC_RD_BITS_PER_WORD
,
&
(
spi
->
bitsPerWord
));
if
(
statusVal
<
0
)
{
perror
(
"Could not set SPI bitsPerWord(RD)...ioctl fail"
);
exit
(
1
);
}
statusVal
=
ioctl
(
spi
->
spifd
,
SPI_IOC_WR_MAX_SPEED_HZ
,
&
(
spi
->
speed
));
if
(
statusVal
<
0
)
{
perror
(
"Could not set SPI speed (WR)...ioctl fail"
);
exit
(
1
);
}
statusVal
=
ioctl
(
spi
->
spifd
,
SPI_IOC_RD_MAX_SPEED_HZ
,
&
(
spi
->
speed
));
if
(
statusVal
<
0
)
{
perror
(
"Could not set SPI speed (RD)...ioctl fail"
);
exit
(
1
);
}
return
statusVal
;
}
/***********************************************************
* spiClose(): Responsible for closing the spidev interface.
* Called in destructor
* *********************************************************/
int
spi_free
(
t_spi
*
spi
){
int
statusVal
=
-
1
;
statusVal
=
close
(
spi
->
spifd
);
if
(
statusVal
<
0
)
{
perror
(
"Could not close SPI device"
);
exit
(
1
);
}
return
statusVal
;
}
/********************************************************************
* This function writes data "data" of length "length" to the spidev
* device. Data shifted in from the spidev device is saved back into
* "data".
* ******************************************************************/
int
spi_WriteRead
(
t_spi
*
spi
,
unsigned
char
*
data
,
int
length
){
struct
spi_ioc_transfer
spid
[
length
];
int
i
=
0
;
int
retVal
=
-
1
;
// one spi transfer for each byte
for
(
i
=
0
;
i
<
length
;
i
++
){
spid
[
i
].
tx_buf
=
(
unsigned
long
)(
data
+
i
);
// transmit from "data"
spid
[
i
].
rx_buf
=
(
unsigned
long
)(
data
+
i
);
// receive into "data"
spid
[
i
].
len
=
sizeof
(
*
(
data
+
i
));
spid
[
i
].
delay_usecs
=
0
;
spid
[
i
].
speed_hz
=
spi
->
speed
;
spid
[
i
].
bits_per_word
=
spi
->
bitsPerWord
;
spid
[
i
].
cs_change
=
0
;
}
retVal
=
ioctl
(
spi
->
spifd
,
SPI_IOC_MESSAGE
(
length
),
&
spid
);
if
(
retVal
<
0
){
perror
(
"Problem transmitting spi data..ioctl"
);
exit
(
1
);
}
return
retVal
;
}
/*************************************************
* Default constructor. Set member variables to
* default values and then call spiOpen()
* ***********************************************/
/*
t_spi *spi_new(){
spi->mode = SPI_MODE_0 ;
spi->bitsPerWord = 8;
spi->speed = 1000000;
spi->spifd = -1;
spi->spiOpen(std::string("/dev/spidev0.0"));
}
*/
/*************************************************
* overloaded constructor. let user set member variables to
* and then call spiOpen()
* ***********************************************/
t_spi
*
spi_new
(
const
char
*
devspi
,
unsigned
char
spiMode
,
unsigned
int
spiSpeed
,
unsigned
char
spibitsPerWord
){
t_spi
*
spi
=
(
t_spi
*
)
malloc
(
sizeof
(
t_spi
));
spi
->
mode
=
spiMode
;
spi
->
bitsPerWord
=
spibitsPerWord
;
spi
->
speed
=
spiSpeed
;
spi
->
spifd
=
-
1
;
spi_Open
(
spi
,
devspi
);
return
spi
;
}
/***********************************************************************
* mcp3008SpiTest.cpp. Sample program that tests the mcp3008Spi class.
* an mcp3008Spi class object (a2d) is created. the a2d object is instantiated
* using the overloaded constructor. which opens the spidev0.0 device with
* SPI_MODE_0 (MODE 0) (defined in linux/spi/spidev.h), speed = 1MHz &
* bitsPerWord=8.
*
* call the spiWriteRead function on the a2d object 20 times. Each time make sure
* that conversion is configured for single ended conversion on CH0
* i.e. transmit -> byte1 = 0b00000001 (start bit)
* byte2 = 0b1000000 (SGL/DIF = 1, D2=D1=D0=0)
* byte3 = 0b00000000 (Don't care)
* receive -> byte1 = junk
* byte2 = junk + b8 + b9
* byte3 = b7 - b0
*
* after conversion must merge data[1] and data[2] to get final result
*
*
*
* *********************************************************************/
//using namespace std;
int
main
(
void
)
{
t_spi
*
a2d
=
spi_new
(
"/dev/spidev0.0"
,
SPI_MODE_0
,
1000000
,
8
);
int
a2dVal
=
0
;
int
a2dChannel
=
1
;
unsigned
char
data
[
3
];
while
(
1
)
{
data
[
0
]
=
1
;
// first byte transmitted -> start bit
data
[
1
]
=
0
b10000000
|
(
((
a2dChannel
&
7
)
<<
4
));
// second byte transmitted -> (SGL/DIF = 1, D2=D1=D0=0)
data
[
2
]
=
0
;
// third byte transmitted....don't care
spi_WriteRead
(
a2d
,
data
,
sizeof
(
data
));
a2dVal
=
0
;
a2dVal
=
(
data
[
1
]
<<
8
)
&
0
b1100000000
;
//merge data[1] & data[2] to get result
a2dVal
|=
(
data
[
2
]
&
0xff
);
usleep
(
10
);
fprintf
(
stderr
,
"%d
\n
"
,
a2dVal
);
}
return
0
;
}
This diff is collapsed.
Click to expand it.
l2ork_addons/tar_em_up.sh
+
22
−
15
View file @
8fe19795
...
@@ -172,20 +172,20 @@ then
...
@@ -172,20 +172,20 @@ then
# read dummy
# read dummy
# if [ $no_cwiid -eq 0 ]
# if [ $no_cwiid -eq 0 ]
# then
# then
cd
l2ork_addons/cwiid/
cd
l2ork_addons/cwiid/
# install cwiid
# install cwiid
aclocal
aclocal
autoconf
autoconf
./configure
--with-python
=
python2
./configure
--with-python
=
python2
make
make
# we have disabled system-wide install because as of 23-03-2013
# we have disabled system-wide install because as of 23-03-2013
# we now statically link disis_wiimote against custom L2Ork version
# we now statically link disis_wiimote against custom L2Ork version
# of the cwiid library
# of the cwiid library
if
[
$sys_cwiid
-eq
1
]
if
[
$sys_cwiid
-eq
1
]
then
then
sudo
make
install
sudo
make
install
fi
fi
cd
../../
cd
../../
# fi
# fi
# clean files that may remain stuck even after doing global make clean (if any)
# clean files that may remain stuck even after doing global make clean (if any)
cd
externals/miXed
cd
externals/miXed
...
@@ -246,7 +246,7 @@ then
...
@@ -246,7 +246,7 @@ then
cat
../../externals/OSCx/src/Makefile |
sed
-e
s/-lpd//g
>
../../externals/OSCx/src/Makefile
cat
../../externals/OSCx/src/Makefile |
sed
-e
s/-lpd//g
>
../../externals/OSCx/src/Makefile
fi
fi
make
install
prefix
=
$inst_dir
make
install
prefix
=
$inst_dir
echo
"copying l2ork-specific externals..."
echo
"copying
pd-
l2ork-specific externals..."
# patch_name
# patch_name
cd
../../l2ork_addons/patch_name
cd
../../l2ork_addons/patch_name
make clean
make clean
...
@@ -283,6 +283,13 @@ then
...
@@ -283,6 +283,13 @@ then
cp
-f
spectdelay~.pd_linux ../../../packages/linux_make/build
$inst_dir
/lib/pd-l2ork/extra
cp
-f
spectdelay~.pd_linux ../../../packages/linux_make/build
$inst_dir
/lib/pd-l2ork/extra
cp
-f
spectdelay~-help.pd ../../../packages/linux_make/build
$inst_dir
/lib/pd-l2ork/extra
cp
-f
spectdelay~-help.pd ../../../packages/linux_make/build
$inst_dir
/lib/pd-l2ork/extra
cp
-f
array
*
../../../packages/linux_make/build
$inst_dir
/lib/pd-l2ork/extra
cp
-f
array
*
../../../packages/linux_make/build
$inst_dir
/lib/pd-l2ork/extra
# install raspberry pi externals (possibly also useful for non-rpi installs)
cd
../raspberry_pi
./makeall.sh
cp
-f
disis_gpio/disis_gpio.pd_linux ../../../packages/linux_make/build
$inst_dir
/lib/pd-l2ork/extra
cp
-f
disis_gpio/disis_gpio-help.pd_linux ../../../packages/linux_make/build
$inst_dir
/lib/pd-l2ork/extra
cp
-f
disis_spi/disis_spi.pd_linux ../../../packages/linux_make/build
$inst_dir
/lib/pd-l2ork/extra
cp
-f
disis_spi/disis_spi-help.pd_linux ../../../packages/linux_make/build
$inst_dir
/lib/pd-l2ork/extra
# return to l2ork_addons folder
# return to l2ork_addons folder
cd
../../
cd
../../
# finish install
# finish install
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment