Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
68b4ad27
Commit
68b4ad27
authored
Jan 15, 2012
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IO SPI slave, configurtion of mode, maxspeed, LSB first and bit per word added
parent
edfeab38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
176 additions
and
10 deletions
+176
-10
otherio/lib/rt/src/os_linux/rt_io_m_spi_slave.c
otherio/lib/rt/src/os_linux/rt_io_m_spi_slave.c
+57
-2
otherio/wbl/mcomp/src/otherio.wb_load
otherio/wbl/mcomp/src/otherio.wb_load
+119
-8
No files found.
otherio/lib/rt/src/os_linux/rt_io_m_spi_slave.c
View file @
68b4ad27
...
@@ -89,6 +89,10 @@ static pwr_tStatus IoCardInit( io_tCtx ctx,
...
@@ -89,6 +89,10 @@ static pwr_tStatus IoCardInit( io_tCtx ctx,
unsigned
int
output_area_offset
=
0
;
unsigned
int
output_area_offset
=
0
;
unsigned
int
output_area_chansize
=
0
;
unsigned
int
output_area_chansize
=
0
;
int
sts
;
int
sts
;
unsigned
char
mode
;
unsigned
char
lsb
;
unsigned
char
bits
;
__u32
speed
;
local
=
(
io_sLocalSPI_Slave
*
)
calloc
(
1
,
sizeof
(
io_sLocalSPI_Slave
));
local
=
(
io_sLocalSPI_Slave
*
)
calloc
(
1
,
sizeof
(
io_sLocalSPI_Slave
));
cp
->
Local
=
local
;
cp
->
Local
=
local
;
...
@@ -102,13 +106,64 @@ static pwr_tStatus IoCardInit( io_tCtx ctx,
...
@@ -102,13 +106,64 @@ static pwr_tStatus IoCardInit( io_tCtx ctx,
return
IO__INITFAIL
;
return
IO__INITFAIL
;
}
}
sts
=
ioctl
(
local
->
fd
,
SPI_IOC_RD_MODE
,
&
local
->
mode
);
/* Set mode */
switch
(
op
->
Mode
)
{
case
pwr_eSPI_ModeEnum_Mode0
:
mode
=
SPI_MODE_0
;
break
;
case
pwr_eSPI_ModeEnum_Mode1
:
mode
=
SPI_MODE_1
;
break
;
case
pwr_eSPI_ModeEnum_Mode2
:
mode
=
SPI_MODE_2
;
break
;
case
pwr_eSPI_ModeEnum_Mode3
:
mode
=
SPI_MODE_3
;
break
;
default:
errh_Error
(
"SPI Slave, invalid mode, '%s'"
,
errno
,
cp
->
Name
);
op
->
Status
=
IOM__SPI_INIT
;
return
IO__INITFAIL
;
}
sts
=
ioctl
(
local
->
fd
,
SPI_IOC_WR_MODE
,
&
mode
);
if
(
sts
<
0
)
{
if
(
sts
<
0
)
{
errh_Error
(
"SPI Slave, init error errno %d, '%s'"
,
errno
,
cp
->
Name
);
errh_Error
(
"SPI Slave,
unable to set mode,
init error errno %d, '%s'"
,
errno
,
cp
->
Name
);
op
->
Status
=
IOM__SPI_INIT
;
op
->
Status
=
IOM__SPI_INIT
;
return
IO__INITFAIL
;
return
IO__INITFAIL
;
}
}
/* Set LSB first encoding */
if
(
op
->
LSB_First
)
lsb
=
1
;
else
lsb
=
0
;
sts
=
ioctl
(
local
->
fd
,
SPI_IOC_WR_LSB_FIRST
,
&
lsb
);
if
(
sts
<
0
)
{
errh_Error
(
"SPI Slave, unable to set LSB first, init error errno %d, '%s'"
,
errno
,
cp
->
Name
);
op
->
Status
=
IOM__SPI_INIT
;
return
IO__INITFAIL
;
}
/* Set bits per word */
bits
=
op
->
BitsPerWord
;
sts
=
ioctl
(
local
->
fd
,
SPI_IOC_WR_BITS_PER_WORD
,
&
bits
);
if
(
sts
<
0
)
{
errh_Error
(
"SPI Slave, unable to set Bits per word, init error errno %d, '%s'"
,
errno
,
cp
->
Name
);
op
->
Status
=
IOM__SPI_INIT
;
return
IO__INITFAIL
;
}
/* Set Max speed */
speed
=
op
->
MaxSpeed
;
if
(
speed
!=
0
)
{
sts
=
ioctl
(
local
->
fd
,
SPI_IOC_WR_MAX_SPEED_HZ
,
&
speed
);
if
(
sts
<
0
)
{
errh_Error
(
"SPI Slave, unable to set Max speed, init error errno %d, '%s'"
,
errno
,
cp
->
Name
);
op
->
Status
=
IOM__SPI_INIT
;
return
IO__INITFAIL
;
}
}
local
->
byte_ordering
=
op
->
ByteOrdering
;
local
->
byte_ordering
=
op
->
ByteOrdering
;
io_bus_card_init
(
ctx
,
cp
,
&
input_area_offset
,
&
input_area_chansize
,
io_bus_card_init
(
ctx
,
cp
,
&
input_area_offset
,
&
input_area_chansize
,
...
...
otherio/wbl/mcomp/src/otherio.wb_load
View file @
68b4ad27
Volume OtherIO $ClassVolume 0.0.250.10
Volume OtherIO $ClassVolume 0.0.250.10
Body SysBody 01-JAN-1970 01:00:00.00
Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X30
0
"
Attr NextOix = "_X30
4
"
Attr NextCix = "_X3
5
"
Attr NextCix = "_X3
6
"
Attr NextTix[0] = "_X1
0
"
Attr NextTix[0] = "_X1
1
"
EndBody
EndBody
Object Type $TypeHier 1 15-NOV-2007 14:35:37.90
Object Type $TypeHier 1 15-NOV-2007 14:35:37.90
Object MotionControl_StatusEnum $TypeDef 1 15-NOV-2007 14:36:24.17
Object MotionControl_StatusEnum $TypeDef 1 15-NOV-2007 14:36:24.17
...
@@ -537,6 +537,39 @@ Volume OtherIO $ClassVolume 0.0.250.10
...
@@ -537,6 +537,39 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndBody
EndObject
EndObject
EndObject
EndObject
Object SPI_ModeEnum $TypeDef 10 15-JAN-2012 10:17:13.34
Body SysBody 15-JAN-2012 10:17:26.16
Attr TypeRef = "pwrs:Type-$Enum"
Attr Elements = 1
EndBody
Object Mode0 $Value 301 15-JAN-2012 10:17:52.48
Body SysBody 15-JAN-2012 10:17:57.54
Attr Text = "Mode0"
Attr PgmName = "Mode0"
EndBody
EndObject
Object Mode1 $Value 302 15-JAN-2012 10:18:15.82
Body SysBody 15-JAN-2012 10:18:18.23
Attr Text = "Mode1"
Attr PgmName = "Mode1"
Attr Value = 1
EndBody
EndObject
Object Mode2 $Value 303 15-JAN-2012 10:18:10.78
Body SysBody 15-JAN-2012 10:18:34.24
Attr Text = "Mode2"
Attr PgmName = "Mode2"
Attr Value = 2
EndBody
EndObject
Object Mode3 $Value 304 15-JAN-2012 10:18:37.17
Body SysBody 15-JAN-2012 10:18:41.01
Attr Text = "Mode3"
Attr PgmName = "Mode3"
Attr Value = 3
EndBody
EndObject
EndObject
EndObject
EndObject
Object Class $ClassHier 2 15-NOV-2007 14:35:40.72
Object Class $ClassHier 2 15-NOV-2007 14:35:40.72
!/**
!/**
...
@@ -5963,13 +5996,44 @@ Volume OtherIO $ClassVolume 0.0.250.10
...
@@ -5963,13 +5996,44 @@ Volume OtherIO $ClassVolume 0.0.250.10
!/**
!/**
! @Version 1.0
! @Version 1.0
! @Group IO
! @Group IO
! @Summary Rack object for SPI Master.
! Rack object for SPI Master.
! The object represents the SPI master.
!
! The object is configured as a child to the node object.
! Each SPI slave is configured as a child with a SPI_Slave object.
!
! @b See also
! @classlink SPI_Slave otherio_spi_slave.html
!*/
Object SPI_Master $ClassDef 35 15-JAN-2012 10:38:09.98
Body SysBody 15-JAN-2012 10:38:18.39
Attr Flags = 10240
EndBody
Object RtBody $ObjBodyDef 1 15-JAN-2012 10:38:27.11
Body SysBody 15-JAN-2012 10:38:27.11
Attr StructName = "SPI_Master"
Attr NextAix = "_X2"
EndBody
Object Super $Attribute 1 15-JAN-2012 10:38:35.30
Body SysBody 15-JAN-2012 10:40:19.18
Attr Flags = 17170432
Attr TypeRef = "BaseComponent:Class-BaseIORack"
EndBody
EndObject
EndObject
EndObject
!/**
! @Version 1.0
! @Group IO
! @Summary Card object for SPI Slave.
! @Summary Card object for SPI Slave.
! Card object for SPI Slave.
! Card object for SPI Slave.
! The object represents a SPI slave connected by the SPI bus.
!
!
! The object is configured as a child to a
generic
Rack object.
! The object is configured as a child to a
SPI_
Rack object.
!
!
! @b See also
! @b See also
! @classlink
BaseIORack basecomponent_baseiorack
.html
! @classlink
SPI_Master otherio_spi_master
.html
!*/
!*/
Object SPI_Slave $ClassDef 26 10-JUL-2011 07:17:19.39
Object SPI_Slave $ClassDef 26 10-JUL-2011 07:17:19.39
Body SysBody 10-JUL-2011 07:17:08.04
Body SysBody 10-JUL-2011 07:17:08.04
...
@@ -5980,7 +6044,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
...
@@ -5980,7 +6044,7 @@ Volume OtherIO $ClassVolume 0.0.250.10
Object RtBody $ObjBodyDef 1 10-JUL-2011 07:19:29.31
Object RtBody $ObjBodyDef 1 10-JUL-2011 07:19:29.31
Body SysBody 10-JUL-2011 07:17:25.64
Body SysBody 10-JUL-2011 07:17:25.64
Attr StructName = "SPI_Slave"
Attr StructName = "SPI_Slave"
Attr NextAix = "_X
56
"
Attr NextAix = "_X
60
"
EndBody
EndBody
!/**
!/**
! Optional description.
! Optional description.
...
@@ -6027,6 +6091,52 @@ Volume OtherIO $ClassVolume 0.0.250.10
...
@@ -6027,6 +6091,52 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndBody
EndObject
EndObject
!/**
!/**
! SPI mode.Each slave may clock may operate at different polarities
! and clock phases. The permutations of polarities and phases are referred
! to as SPI modes.
!
! Mode Clock pol Phase
! SPI_MODE_0 0 0
! SPI_MODE_1 0 1
! SPI_MODE_2 1 0
! SPI_MODE_3 1 1
!*/
Object Mode $Attribute 56 15-JAN-2012 10:14:40.11
Body SysBody 15-JAN-2012 10:19:28.91
Attr PgmName = "Mode"
Attr TypeRef = "OtherIO:Type-SPI_ModeEnum"
EndBody
EndObject
!/**
! Number of bits per word for the transfer.
!*/
Object BitsPerWord $Attribute 57 15-JAN-2012 10:15:07.96
Body SysBody 15-JAN-2012 10:15:29.14
Attr PgmName = "BitsPerWord"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Bit justification use to transfer words.
! 0 for MSB first and 1 for LSB first.
!*/
Object LSB_First $Attribute 58 15-JAN-2012 10:15:46.96
Body SysBody 15-JAN-2012 10:16:06.24
Attr PgmName = "LSB_First"
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! Maximum SPI transfer speed in Hz.
! If 0, the default maximum speed will not be changed.
!*/
Object MaxSpeed $Attribute 59 15-JAN-2012 10:16:16.00
Body SysBody 15-JAN-2012 10:16:29.49
Attr PgmName = "MaxSpeed"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Byte ordering for slave.
! Byte ordering for slave.
!*/
!*/
Object ByteOrdering $Attribute 38 10-JUL-2011 07:17:08.04
Object ByteOrdering $Attribute 38 10-JUL-2011 07:17:08.04
...
@@ -6147,8 +6257,9 @@ Volume OtherIO $ClassVolume 0.0.250.10
...
@@ -6147,8 +6257,9 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndBody
EndBody
EndObject
EndObject
Object Template SPI_Slave 2154528768 01-JAN-1970 01:00:00.00
Object Template SPI_Slave 2154528768 01-JAN-1970 01:00:00.00
Body RtBody 1
0-JUL-2011 07:20:38.66
Body RtBody 1
5-JAN-2012 10:20:33.58
Attr Process = 1
Attr Process = 1
Attr BitsPerWord = 8
Attr ErrorSoftLimit = 50
Attr ErrorSoftLimit = 50
Attr ErrorHardLimit = 100
Attr ErrorHardLimit = 100
EndBody
EndBody
...
...
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