コード例 #1
0
ファイル: main.c プロジェクト: JackABK/STM32_FreeRTOS8.0.1
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40xx.s/startup_stm32f427x.s) before to branch to 
       application main. 
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */

  /* Initialize LEDs available on EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);  

  /* NVIC Configuration */
  NVIC_Configuration();

  /*------------------------------ SD Init ---------------------------------- */
  if((Status = SD_Init()) != SD_OK)
  {
    STM_EVAL_LEDOn(LED4); 
  }
        
  while((Status == SD_OK) && (uwSDCardOperation != SD_OPERATION_END) && (SD_Detect()== SD_PRESENT))
  {
    switch(uwSDCardOperation)
    {
      /*-------------------------- SD Erase Test ---------------------------- */
      case (SD_OPERATION_ERASE):
      {
        SD_EraseTest();
        uwSDCardOperation = SD_OPERATION_BLOCK;
        break;
      }
      /*-------------------------- SD Single Block Test --------------------- */
      case (SD_OPERATION_BLOCK):
      {
        SD_SingleBlockTest();
        uwSDCardOperation = SD_OPERATION_MULTI_BLOCK;
        break;
      }       
      /*-------------------------- SD Multi Blocks Test --------------------- */
      case (SD_OPERATION_MULTI_BLOCK):
      {
        SD_MultiBlockTest();
        uwSDCardOperation = SD_OPERATION_END;
        break;
      }              
    }
  }
  
  /* Infinite loop */
  while (1)
  {
  }
}
コード例 #2
0
ファイル: main.c プロジェクト: Ribster/the-hacker-workshop
int main (void)
{
        initUsart ();
        logf ("Init\r\n");

        /*!< At this stage the microcontroller clock setting is already configured,
         this is done through SystemInit() function which is called from startup
         files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s)
         before to branch to application main. To reconfigure the default setting
         of SystemInit() function, refer to system_stm32f4xx.c file
         */

        /* NVIC Configuration */
        NVIC_Configuration ();
        logf ("NVIC_Configuration\r\n");

        /*------------------------------ SD Init ---------------------------------- */
        if ((Status = SD_Init ()) != SD_OK) {
                logf ("SD_Init failed\r\n");
        }
        else {
                logf ("SD_Init OK\r\n");
        }

        while ((Status == SD_OK) && (uwSDCardOperation != SD_OPERATION_END) && (SD_Detect () == SD_PRESENT)) {
                switch (uwSDCardOperation) {
                        /*-------------------------- SD Single Block Test --------------------- */
                        case (SD_OPERATION_BLOCK):
                        {
                                SD_SingleBlockTest ();
                                uwSDCardOperation = SD_OPERATION_ERASE;
                                break;
                        }
                        /*-------------------------- SD Erase Test ---------------------------- */
                        case (SD_OPERATION_ERASE):
                        {
                                SD_EraseTest ();
                                uwSDCardOperation = SD_OPERATION_MULTI_BLOCK;
                                break;
                        }
                        /*-------------------------- SD Multi Blocks Test --------------------- */
                        case (SD_OPERATION_MULTI_BLOCK):
                        {
                                SD_MultiBlockTest ();
                                uwSDCardOperation = SD_OPERATION_END;
                                break;
                        }
                }
        }

        /* Infinite loop */
        while (1) {
        }
}
コード例 #3
0
ファイル: sdio_debug.c プロジェクト: jssmile/Plotter
void SDIO_test(void)
{
    SD_Error error;
    // interrupt config
    SD_NVIC_Configuration();
    //SD init
    error = SD_Init();
    printf("test SDIO without FS\n\r");

    if(error == SD_OK) printf("SD_Init Success.\n\r");
    else{
	printf("SD_Init fail.\n\r");
	printf("status:\t%d\n\r",error);
    }

    printf("CardType:\t%d\n\r",SDCardInfo.CardType);
    printf("CardCapacity:\t%d\n\r",SDCardInfo.CardCapacity);
    printf("CardBlockSize:\t%d\n\r",SDCardInfo.CardBlockSize);
    printf("ManufactureID:\t%d\n\r",SDCardInfo.SD_cid.ManufacturerID);
    printf("RCA:\t%d\n\r",SDCardInfo.RCA);


    while((error == SD_OK) && (uwSDCardOperation != SD_OPERATION_END))
    {
	switch(uwSDCardOperation)
	{
	    /* -------------------SD single block test--------------------- */
	    case(SD_OPERATION_BLOCK):
	    {
		SD_SingleBlockTest();
		uwSDCardOperation = SD_OPERATION_ERASE;
		break;
	    }
	    /* -------------------SD Erase test--------------------- */
	    case(SD_OPERATION_ERASE):
	    {
		SD_EraseTest();
		uwSDCardOperation = SD_OPERATION_MULTI_BLOCK;
		break;
	    }
	    /* -------------------SD single block test--------------------- */
	    case(SD_OPERATION_MULTI_BLOCK):
	    {
		SD_MultiBlockTest();
		uwSDCardOperation = SD_OPERATION_END;
		break;
	    }
	}
    }
}
コード例 #4
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */

  /* Initialize LEDs available on STM324xG-EVAL board *************************/
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);  

  STM324xG_LCD_Init();
  LCD_Clear(Black);
  LCD_SetBackColor(Black);
  LCD_SetTextColor(White);

  /* Interrupt Config */
  NVIC_Configuration();

  /*------------------------------ SD Init ---------------------------------- */
  if((Status = SD_Init()) != SD_OK)
  {
    STM_EVAL_LEDOn(LED4); 
	LCD_SetTextColor(Red);
	LCD_DisplayStringLine(LCD_LINE_0, "SD_Init failed");
  }
  else
  {
    LCD_DisplayStringLine(LCD_LINE_0, "SD_Init ok");
  }
        
  while((Status == SD_OK) && (SDCardOperation != SD_OPERATION_END) && (SD_Detect()== SD_PRESENT))
  {
    switch(SDCardOperation)
    {
      /*-------------------------- SD Erase Test ---------------------------- */
      case (SD_OPERATION_ERASE):
      {
        SD_EraseTest();
        SDCardOperation = SD_OPERATION_BLOCK;
	    LCD_DisplayStringLine(LCD_LINE_1, "SD_EraseTest");
        break;
      }
      /*-------------------------- SD Single Block Test --------------------- */
      case (SD_OPERATION_BLOCK):
      {
        SD_SingleBlockTest();
        SDCardOperation = SD_OPERATION_MULTI_BLOCK;
		LCD_DisplayStringLine(LCD_LINE_1, "SD_SingleBlockTest");
        break;
      }       
      /*-------------------------- SD Multi Blocks Test --------------------- */
      case (SD_OPERATION_MULTI_BLOCK):
      {
        SD_MultiBlockTest();
        SDCardOperation = SD_OPERATION_END;
		LCD_DisplayStringLine(LCD_LINE_1, "SD_MultiBlockTest");
        break;
      }              
    }
	delay(10000000);
  }
  
  LCD_DisplayStringLine(LCD_LINE_3, "End");
  /* Infinite loop */
  while (1)
  {}
}
コード例 #5
0
ファイル: main.c プロジェクト: lilpako/ministm32-bsp
/**
 * @brief	Main program
 * @param	None
 * @retval	None
 */
int main(void)
{
	uint16_t u16Menu=0;
	uint32_t u32FlashID = 0;

	uint8_t Tx_Buffer[] = "miniSTM32 SPI Flash Test Data";
	uint8_t Rx_Buffer[READ_BUFFER_SIZE] = {0x20};

	/* Initialize SysTick - 1msec resolution */
	SysTick_Config(SystemCoreClock / 1000);

	/* Configure the NVIC Preemption Priority Bits */
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

	/* Initialize main board peripherals */
	MBD_Init();
	printf("miniSTM32 mainboard initialized\n");

	/* Initialize SPI FLASH driver */
	SFL_Init();
	printf("serial FLASH  initialized\n");

#ifdef SD_RAW_ACCESS
	/* Initialize SD subsystem : for FAT test it is automatic */
	if(SDC_Init() == SD_OK)
	{
		printf("SD interface initialized\n");
	}
	else
	{
		printf("SD interface init fail\n");
	}
#endif
        
	while (1) 
	{
		/* main menu controlled by pushbutton interrupt */
		if( uIRQFlag == MAIN_BTN_EXTI_LINE ) {

			/* clear button interrupt flag */
			uIRQFlag = 0;

			if( u16Menu == MENU_LED_ON ) {
				MBD_LEDOn();
				printf("LED1 Turned On\n");
			}
			else if( u16Menu == MENU_LED_OFF ) {
				MBD_LEDOff();
				printf("LED1 Turned Off\n");
			}
			else if( u16Menu == MENU_FLASH_READID ) {
				u32FlashID = SFL_ReadID();
				printf("JEDEC Flash ID: %X\n", u32FlashID);
			}
			else if( u16Menu == MENU_FLASH_WRITE ) {
				SFL_Erase(EBSIZE_4KB, FLASH_ADDRESS);
				SFL_WriteBuffer(Tx_Buffer, FLASH_ADDRESS, sizeof(Tx_Buffer));
				printf("FLASH Write Data: %s\n", Tx_Buffer);
			}
			else if( u16Menu == MENU_FLASH_READ ) {
				SFL_ReadBuffer(Rx_Buffer, FLASH_ADDRESS, sizeof(Rx_Buffer));
				printf("FLASH Read Back: %s\n", Rx_Buffer);
			}
			else if( u16Menu == MENU_FLASH_ERASE ) {
				SFL_Erase(EBSIZE_4KB, FLASH_ADDRESS);
				printf("FLASH Erase Block: Data Erased\n");
			}
			else if( u16Menu == MENU_FLASH_ERASECHECK ) {
				SFL_ReadBuffer(Rx_Buffer, FLASH_ADDRESS, sizeof(Rx_Buffer));
				printf("FLASH Read Data Again: %s\n", Rx_Buffer);
			}

#ifdef SD_RAW_ACCESS
			else if( u16Menu == MENU_SD_ERASE ) {
//			#ifdef SD_DMA_MODE
				SD_EraseTest();
//			#else
//				printf("EraseTest does not support SD_POLLING_MODE\n");
//			#endif
			}
			else if( u16Menu == MENU_SD_BLOCK ) {
				SD_SingleBlockTest();
			}
			else if( u16Menu == MENU_SD_MULTIBLOCK ) {
//			#ifdef SD_DMA_MODE
				SD_MultiBlockTest();
//			#else
//				printf("MultiBlockTest does not support SD_POLLING_MODE\n");
//			#endif
			}
#else
			else if( u16Menu == MENU_FAT_TEST ) {
				if(FAT_Test() == PASSED)
					printf("FAT Test Passed\n");
				else
					printf("FAT Test Failed\n");;
			}
#endif // SD_RAW_ACCESS

			if( ++u16Menu == MENU_END )
				u16Menu = 0;

		}

		/* usual household routine goes here */
		{
		}
	}
}