[En-Nut-Discussion] STM32F1 SPI
kontais at aliyun.com
kontais at aliyun.com
Thu Feb 18 09:41:20 CET 2016
Hi,
I have a stm32f107vc board, the spi sd driver can't work, I do some changes, hope help for somebody who wan use spi sd on smt32f107.
I change base on svn://svn.code.sf.net/p/ethernut/code/trunk rev6130
1. C:\Users\kontais\Desktop\Temp\ethernut-r6130_Change\nut\app\Makeburn.cm3-jlink
jlink burn scripts
2. C:\Users\kontais\Desktop\Temp\ethernut-r6130_Change\nut\app\Makefile
make clean fix
3.C:\Users\kontais\Desktop\Temp\ethernut-r6130_Change\nut\arch\cm3\board\stm3210c_eval.c
GPIO use on my board
4.C:\Users\kontais\Desktop\Temp\ethernut-r6130_Change\nut\arch\cm3\dev\stm\stm32_gpioirq.c
share irq issue, already fixed on new code
5. C:\Users\kontais\Desktop\Temp\ethernut-r6130_Change\nut\arch\cm3\dev\stm\stm32_spi.c
5.1 delete SPI_IRQ_MODE, #if SPIBUS_MODE == IRQ_MODE
5.2 use 10MHz, no 2MHz, 2MHz will error when use POLL_MODE,
the root case I don't kown, but find this set cause POLL_MODE error I use three weeks.
static void SetPinSpeed( NUTSPINODE * node, uint32_t rate)
{
#if defined (MCU_STM32F1)
if (rate_div64k * OSPEED_MULT < ospeed_values[2])
ospeed_set = 1; /* max speed 10 MHz */
5.3 rewrite Stm32SpiBusTransfer
make sure dma and poll can work ok, can add "if (xlen * clk_ratio > SCHEDULE_CYCLES/8) {"
for small transfer use poll.
/* Follow procedure "Disabling the SPI" */
while(GpioPinGet(SPIBUS_SCK_PORT,SPIBUS_SCK_PIN)); // if use SPI_MODE_3 need this line
while(!(GpioPinGet(SPIBUS_SCK_PORT,SPIBUS_SCK_PIN)));
while(GpioPinGet(SPIBUS_SCK_PORT,SPIBUS_SCK_PIN));
6. C:\Users\kontais\Desktop\Temp\ethernut-r6130_Change\nut\dev\spi_mmc.c
6.1 add CardRelease
static void CardRelease(NUTSPINODE * node)
6.2 CardAllocate add wait flag for CMD0
static NUTSPIBUS *CardAllocate(NUTSPINODE * node, uint8_t wait)
/* If card has been hot pluged, the card will always out busy, case
* allocate wait timeout even you want to send CMD0, so CMD0 no need
* to wait.
*/
if (cmd == MMCMD_GO_IDLE_STATE) {
wait = 0;
}
6.3 Add CardReset
some card need Reset twice
7. C:\Users\kontais\Desktop\Temp\ethernut-r6130_Change\nut\dev\spi_mmc_gpio.c
use GpioCreateIrqHandler, not GpioRegisterIrqHandler
SPI_MODE_3 and SPI_MODE_0 are ok.
kontais at aliyun.com
From: Achim
Date: 2016-02-12 19:24
To: en-nut-discussion at egnite.de
Subject: [En-Nut-Discussion] STM32F1 SPI
Hi,
has anybody tried to run the SPI on a STM32F1?
Best regards,
Achim
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
More information about the En-Nut-Discussion
mailing list