Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
c754d801
Commit
c754d801
authored
May 27, 2015
by
Daniel Campora
Browse files
cc3200: Simplify SPI polarity and phase checks in constructor.
parent
95104b0f
Changes
1
Hide whitespace changes
Inline
Side-by-side
cc3200/mods/pybspi.c
View file @
c754d801
...
...
@@ -224,23 +224,8 @@ STATIC mp_obj_t pyb_spi_init_helper(pyb_spi_obj_t *self, mp_uint_t n_args, const
uint
polarity
=
args
[
3
].
u_int
;
uint
phase
=
args
[
4
].
u_int
;
uint
submode
;
if
(
polarity
)
{
if
(
phase
)
{
// polarity = 1, phase = 1
submode
=
3
;
}
else
{
// polarity = 1, phase = 0
submode
=
2
;
}
}
else
{
if
(
phase
)
{
// polarity = 0, phase = 1
submode
=
1
;
}
else
{
// polarity = 0, phase = 0
submode
=
0
;
}
if
(
polarity
>
1
||
phase
>
1
)
{
goto
invalid_args
;
}
uint
nss
=
args
[
5
].
u_int
;
...
...
@@ -254,7 +239,7 @@ STATIC mp_obj_t pyb_spi_init_helper(pyb_spi_obj_t *self, mp_uint_t n_args, const
self
->
config
=
bits
|
nss
|
SPI_SW_CTRL_CS
|
SPI_4PIN_MODE
|
SPI_TURBO_OFF
;
self
->
polarity
=
polarity
;
self
->
phase
=
phase
;
self
->
submode
=
submod
e
;
self
->
submode
=
(
polarity
<<
1
)
|
phas
e
;
// init the bus
pybspi_init
((
const
pyb_spi_obj_t
*
)
self
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment