Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
cm-projects
RIOT
Commits
2e2ec378
Commit
2e2ec378
authored
9 years ago
by
DipSwitch
Browse files
Options
Downloads
Patches
Plain Diff
cpu/stm32f1/spi: add SPI peripheral 1 and 2
parent
d3558d26
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cpu/stm32f1/periph/spi.c
+73
-1
73 additions, 1 deletion
cpu/stm32f1/periph/spi.c
with
73 additions
and
1 deletion
cpu/stm32f1/periph/spi.c
+
73
−
1
View file @
2e2ec378
...
...
@@ -32,7 +32,7 @@
#include
"debug.h"
/* guard file in case no SPI device is defined */
#if SPI_0_EN
#if SPI_0_EN
|| SPI_1_EN || SPI_2_EN
/**
* @brief Array holding one pre-initialized mutex for each SPI device
...
...
@@ -63,6 +63,22 @@ int spi_init_master(spi_t dev, spi_conf_t conf, spi_speed_t speed)
SPI_0_CLKEN
();
break
;
#endif
#ifdef SPI_1_EN
case
SPI_1
:
spi
=
SPI_1_DEV
;
bus_div
=
SPI_1_BUS_DIV
;
SPI_1_CLKEN
();
break
;
#endif
#ifdef SPI_2_EN
case
SPI_2
:
spi
=
SPI_2_DEV
;
bus_div
=
SPI_2_BUS_DIV
;
SPI_2_CLKEN
();
break
;
#endif
default:
return
-
1
;
}
...
...
@@ -119,6 +135,22 @@ int spi_conf_pins(spi_t dev)
miso
=
SPI_0_MISO_PIN
;
break
;
#endif
#ifdef SPI_1_EN
case
SPI_1
:
clk
=
SPI_1_CLK_PIN
;
mosi
=
SPI_1_MOSI_PIN
;
miso
=
SPI_1_MISO_PIN
;
break
;
#endif
#ifdef SPI_2_EN
case
SPI_2
:
clk
=
SPI_2_CLK_PIN
;
mosi
=
SPI_2_MOSI_PIN
;
miso
=
SPI_2_MISO_PIN
;
break
;
#endif
default:
return
-
1
;
}
...
...
@@ -159,6 +191,18 @@ int spi_transfer_byte(spi_t dev, char out, char *in)
spi
=
SPI_0_DEV
;
break
;
#endif
#ifdef SPI_1_EN
case
SPI_1
:
spi
=
SPI_1_DEV
;
break
;
#endif
#ifdef SPI_2_EN
case
SPI_2
:
spi
=
SPI_2_DEV
;
break
;
#endif
default:
return
-
1
;
}
...
...
@@ -204,6 +248,20 @@ void spi_poweron(spi_t dev)
SPI_0_DEV
->
CR1
|=
SPI_CR1_SPE
;
/* turn SPI peripheral on */
break
;
#endif
#ifdef SPI_1_EN
case
SPI_1
:
SPI_1_CLKEN
();
SPI_1_DEV
->
CR1
|=
SPI_CR1_SPE
;
/* turn SPI peripheral on */
break
;
#endif
#ifdef SPI_2_EN
case
SPI_2
:
SPI_2_CLKEN
();
SPI_2_DEV
->
CR1
|=
SPI_CR1_SPE
;
/* turn SPI peripheral on */
break
;
#endif
}
}
...
...
@@ -216,6 +274,20 @@ void spi_poweroff(spi_t dev)
SPI_0_CLKDIS
();
break
;
#endif
#ifdef SPI_1_EN
case
SPI_1
:
SPI_1_DEV
->
CR1
&=
~
(
SPI_CR1_SPE
);
/* turn SPI peripheral off */
SPI_1_CLKDIS
();
break
;
#endif
#ifdef SPI_2_EN
case
SPI_2
:
SPI_2_DEV
->
CR1
&=
~
(
SPI_CR1_SPE
);
/* turn SPI peripheral off */
SPI_2_CLKDIS
();
break
;
#endif
}
}
...
...
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