Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
fwatch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
fwatch
Commits
a808ef64
Commit
a808ef64
authored
Jul 31, 2014
by
Xavier Piroux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The SPI drivers works (we see expected stuff with data analyzer)
parent
010b7f93
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
404 deletions
+50
-404
sd.c
sw/common/drivers/sd.c
+32
-2
sd.h
sw/common/drivers/sd.h
+2
-5
simple_spi_sd.c
sw/os-comparison/simple_spi_sd/src/simple_spi_sd.c
+16
-397
No files found.
sw/common/drivers/sd.c
View file @
a808ef64
...
...
@@ -67,10 +67,14 @@ static void sd_spi_init(void) {
GPIO_Mode_TypeDef
gpioModeCs
=
gpioModePushPull
;
GPIO_Mode_TypeDef
gpioModeClk
=
gpioModePushPull
;
//enable clocks for pins and for associated USART
CMU_ClockEnable
(
SD_SPI_CLOCK
,
true
);
usartInit
.
baudrate
=
SD_SPI_BAUDRATE
;
CMU_ClockEnable
(
cmuClock_GPIO
,
true
)
;
usartInit
.
baudrate
=
SD_SPI_LO_FREQ
;
usartInit
.
msbf
=
true
;
USART_InitSync
(
SD_SPI_UNIT
,
&
usartInit
);
SD_SPI_UNIT
->
ROUTE
=
(
USART_ROUTE_CLKPEN
|
USART_ROUTE_TXPEN
|
USART_ROUTE_RXPEN
|
USART_ROUTE_CSPEN
|
(
SD_SPI_LOCATION
<<
8
));
GPIO_PinModeSet
(
SD_PORT_MOSI
,
SD_PIN_MOSI
,
gpioModeMosi
,
0
);
/* MOSI */
...
...
@@ -80,10 +84,32 @@ static void sd_spi_init(void) {
sd_power_init
();
}
//this function writes and reads
//TODO: supprimer cet appel externe (permet d'ignorer le static)
void
sd_spi_init_not_static
(
void
)
{
sd_spi_init
();
}
/**************************************************************************//**
* @brief Set SPI clock to a low frequency suitable for initial
* card initialization.
*****************************************************************************/
static
void
sd_spi_clock_slow
(
void
)
{
USART_BaudrateSyncSet
(
SD_SPI_UNIT
,
0
,
SD_SPI_LO_FREQ
);
}
/**************************************************************************//**
* @brief Set SPI clock to maximum frequency.
*****************************************************************************/
static
void
sd_spi_clock_fast
(
void
)
{
USART_BaudrateSyncSet
(
SD_SPI_UNIT
,
0
,
SD_SPI_HI_FREQ
);
}
//this function writes and reads on SPI
static
uint8_t
sd_spi_transfer_byte
(
uint8_t
txData
)
{
return
USART_SpiTransfer
(
SD_SPI_UNIT
,
txData
);
}
//TODO: supprimer cet appel externe (permet d'ignorer le static)
uint8_t
sd_spi_transfer_byte_not_static
(
uint8_t
txData
)
{
return
sd_spi_transfer_byte
(
txData
);
}
//this function writes and reads (buffers must have the same length)
static
void
sd_spi_transfer
(
uint8_t
*
txData
,
uint8_t
*
rxData
,
int
length
)
{
int
i
;
...
...
@@ -127,6 +153,8 @@ uint32_t sd_init(void) {
int
i
=
0
;
sd_spi_init
();
sd_power
(
1
);
//TODO: //set low speed for clock
//sd_spi_clock_slow();
/* initializes the micro SD card */
sd_send_command_r1
(
SD_CMD0
,
0
);
do
{
...
...
@@ -138,6 +166,8 @@ uint32_t sd_init(void) {
return
0
;
}
sd_send_block_length
(
SD_SECTOR_SIZE
);
//TODO: //set high speed for clock
//sd_spi_clock_fast();
return
1
;
//TODO: is the init finished?
}
...
...
sw/common/drivers/sd.h
View file @
a808ef64
...
...
@@ -29,13 +29,10 @@
#include "em_gpio.h"
/* Defines */
#define HFRCO_FREQUENCY 14000000
#define SD_SPI_PERCLK_FREQUENCY HFRCO_FREQUENCY
/* Peripherals */
#define SD_SPI_HI_FREQ 16000000
#define SD_SPI_LO_FREQ 100000
#define SD_SPI_CLOCK cmuClock_USART1
#define SD_SPI_BAUDRATE 1000000
#define SD_SPI_UNIT USART1
#define SD_SPI_LOCATION 1
...
...
sw/os-comparison/simple_spi_sd/src/simple_spi_sd.c
View file @
a808ef64
This diff is collapsed.
Click to expand it.
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