Mercurial > ~darius > hgwebdir.cgi > stm32temp
comparison hw.c @ 49:ace431a0d0f5
Add SDIO code poached from STM. Use FatFS to read from SD card.
LFN doesn't work reliably so it's disabled for now.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Wed, 03 Apr 2013 23:34:20 +1030 |
parents | 2db4bb90cfca |
children | bb52e6dad784 |
comparison
equal
deleted
inserted
replaced
48:2f336d212c74 | 49:ace431a0d0f5 |
---|---|
295 volatile uint32_t *DWT_CONTROL = (uint32_t *)0xe0001000; | 295 volatile uint32_t *DWT_CONTROL = (uint32_t *)0xe0001000; |
296 volatile uint32_t *SCB_DEMCR = (uint32_t *)0xe000edfc; | 296 volatile uint32_t *SCB_DEMCR = (uint32_t *)0xe000edfc; |
297 | 297 |
298 *SCB_DEMCR = *SCB_DEMCR | 0x01000000; | 298 *SCB_DEMCR = *SCB_DEMCR | 0x01000000; |
299 *DWT_CONTROL = *DWT_CONTROL | 1 ; // enable the counter | 299 *DWT_CONTROL = *DWT_CONTROL | 1 ; // enable the counter |
300 | |
301 /* Setup SDIO | |
302 * See SD_LowLevelInit from libs/STM32F10x_StdPeriph_Lib_V3.5.0/Utilities/STM32_EVAL/STM3210E_EVAL/stm3210e_eval.c | |
303 */ | |
304 | |
305 /* GPIOC and GPIOD Periph clock enable */ | |
306 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE); | |
307 | |
308 /* Configure SDIO pins for AF | |
309 PC8 -> SD0 | |
310 PC9 -> SD1 | |
311 PC10 -> SD2 | |
312 PC11 -> SD3 | |
313 PC12 -> SCK | |
314 */ | |
315 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12; | |
316 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; | |
317 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; | |
318 GPIO_Init(GPIOC, &GPIO_InitStructure); | |
319 | |
320 /* Configure PD2 -> CMD SDIO pin for AF */ | |
321 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; | |
322 GPIO_Init(GPIOD, &GPIO_InitStructure); | |
323 | |
324 /* Enable the SDIO AHB Clock */ | |
325 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_SDIO, ENABLE); | |
326 | |
327 /* Enable the DMA2 Clock */ | |
328 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE); | |
300 } | 329 } |