这篇教程C++ BSP_SD_IsDetected函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中BSP_SD_IsDetected函数的典型用法代码示例。如果您正苦于以下问题:C++ BSP_SD_IsDetected函数的具体用法?C++ BSP_SD_IsDetected怎么用?C++ BSP_SD_IsDetected使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了BSP_SD_IsDetected函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: k_StorageInit/** * @brief Storage drives initialization * @param None * @retval None */void k_StorageInit(void){ /* Link the USB Host disk I/O driver */ FATFS_LinkDriver(&USBH_Driver, USBDISK_Drive); /* Link the micro SD disk I/O driver */ FATFS_LinkDriver(&SD_Driver, mSDDISK_Drive); /* Create USB background task */ osThreadDef(STORAGE_Thread, StorageThread, osPriorityBelowNormal, 0, 2 * configMINIMAL_STACK_SIZE); osThreadCreate (osThread(STORAGE_Thread), NULL); /* Create Storage Message Queue */ osMessageQDef(osqueue, 10, uint16_t); StorageEvent = osMessageCreate (osMessageQ(osqueue), NULL); /* Init Host Library */ USBH_Init(&hUSB_Host, USBH_UserProcess, 0); /* Add Supported Class */ USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS); /* Start Host Process */ USBH_Start(&hUSB_Host); /* Enable SD Interrupt mode */ BSP_SD_Init(); BSP_SD_ITConfig(); if(BSP_SD_IsDetected()) { osMessagePut ( StorageEvent, MSDDISK_CONNECTION_EVENT, 0); }}
开发者ID:451506709,项目名称:automated_machine,代码行数:39,
示例2: SD_StorageInit/** * @brief Initializes the SD Storage. * @param None * @retval Status */uint8_t SD_StorageInit(void){ /*Initializes the SD card device*/ BSP_SD_Init(); /* Check if the SD card is plugged in the slot */ if(BSP_SD_IsDetected() == SD_PRESENT ) { /* Link the SD Card disk I/O driver */ if(FATFS_LinkDriver(&SD_Driver, SD_Path) == 0) { if((f_mount(&SD_FatFs, (TCHAR const*)SD_Path, 0) != FR_OK)) { /* FatFs Initialization Error */ LCD_ErrLog("Cannot Initialize FatFs! /n"); return 1; } else { LCD_DbgLog ("INFO : FatFs Initialized! /n"); } } } else { LCD_ErrLog("SD card NOT plugged /n"); return 1; } return 0;}
开发者ID:eemei,项目名称:library-stm32f4,代码行数:35,
示例3: AUDIO_Start/** * @brief Starts Audio streaming. * @param idx: File index * @retval Audio error */AUDIO_ErrorTypeDef AUDIO_Start(uint8_t idx){ uint32_t bytesread; if((FileList.ptr > idx) && (BSP_SD_IsDetected())) { f_close(&wav_file); AUDIO_GetFileInfo(idx, &wav_info); audio_state = AUDIO_STATE_CONFIG; /* Set Frequency */ USBH_AUDIO_SetFrequency(&hUSBHost, wav_info.SampleRate, wav_info.NbrChannels, wav_info.BitPerSample); /* Fill whole buffer at first time */ if(f_read(&wav_file, &buffer_ctl.buff[0], AUDIO_BLOCK_SIZE * AUDIO_BLOCK_NBR, (void *)&bytesread) == FR_OK) { if(bytesread != 0) { return AUDIO_ERROR_NONE; } } buffer_ctl.in_ptr = 0; } return AUDIO_ERROR_IO;}
开发者ID:acrepina,项目名称:STM32F7_serverWEB,代码行数:39,
示例4: HAL_GPIO_EXTI_Callback/** * @brief EXTI line detection callbacks. * @param GPIO_Pin: Specifies the pins connected EXTI line * @retval None */void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){ if(GPIO_Pin==SD_DETECT_PIN) { /* Check SD card detect pin */ BSP_SD_IsDetected(); }}
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:13,
示例5: Save_Picture/** * @brief Saves the picture in microSD. * @param None * @retval None */void Save_Picture(void){ FRESULT res1, res2; /* FatFs function common result code */ uint32_t byteswritten = 0; /* File write count */ static uint32_t counter = 0; uint8_t str[30]; /* Check if the SD card is plugged in the slot */ if(BSP_SD_IsDetected() != SD_PRESENT) { Error_Handler(); } else { /* Format the string */ sprintf((char *)str, "image_%lu.bmp", counter); /*##-1- Prepare the image to be saved ####################################*/ Prepare_Picture(); /*##-2- Create and Open a new bmp file object with write access ##########*/ if(f_open(&MyFile, (const char*)str, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK) { /* 'image.bmp' file Open for write Error */ Error_Handler(); } else { /*##-3- Write data to the BMP file #####################################*/ /* Write the BMP header */ res1 = f_write(&MyFile, (uint32_t *)aBMPHeader, 54, (void *)&byteswritten); /* Write the BMP file */ res2 = f_write(&MyFile, (uint32_t *)CONVERTED_FRAME_BUFFER, ((BSP_LCD_GetYSize() - 80)*(BSP_LCD_GetXSize() - 80)*2), (void *)&byteswritten); if((res1 != FR_OK) || (res2 != FR_OK) || (byteswritten == 0)) { /* 'image.bmp' file Write or EOF Error */ Error_Handler(); } else { /*##-4- Close the open BMP file ######################################*/ f_close(&MyFile); /* Success of the demo: no error occurrence */ BSP_LED_On(LED1); /* Wait for 2s */ HAL_Delay(2000); /* Select Layer 1 */ BSP_LED_Off(LED1); counter++; } } }}
开发者ID:pierreroth64,项目名称:STM32Cube_FW_F4,代码行数:63,
示例6: BSP_SD_ITConfig/** * @brief Configures Interrupt mode for SD detection pin. * @retval Returns 0 */uint8_t BSP_SD_ITConfig(void){ /* Configure Interrupt mode for SD detection pin */ /* Note: disabling exti mode can be done calling SD_DeInit() */ UseExtiModeDetection = 1; BSP_SD_IsDetected(); return 0;}
开发者ID:robbie-cao,项目名称:stm32f4-discovery,代码行数:13,
示例7: BSP_SD_DetectCallback/** * @brief SD detect callback * @param None * @retval None */ void BSP_SD_DetectCallback(void){ if(BSP_SD_IsDetected()) { osMessagePut ( StorageEvent, MSDDISK_CONNECTION_EVENT, 0); } else { osMessagePut ( StorageEvent, MSDDISK_DISCONNECTION_EVENT, 0); }}
开发者ID:Bosvark,项目名称:STM32Cube_FW_F4_V1.1.0,代码行数:16,
示例8: STORAGE_Write/** * @brief Writes data into the medium. * @param lun: Logical unit number * @param blk_addr: Logical block address * @param blk_len: Blocks number * @retval Status (0 : Ok / -1 : Error) */int8_t STORAGE_Write(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len){ int8_t ret = -1; if(BSP_SD_IsDetected() != SD_NOT_PRESENT) { BSP_SD_WriteBlocks_DMA((uint32_t *)buf, blk_addr * STORAGE_BLK_SIZ, STORAGE_BLK_SIZ, blk_len); ret = 0; } return ret;}
开发者ID:EarnestHein89,项目名称:STM32Cube_FW_F4,代码行数:18,
示例9: BSP_SD_DetectCallback/** * @brief SD detect callback * @param None * @retval None */ void BSP_SD_DetectCallback(void){ if((BSP_SD_IsDetected())) { /* After sd disconnection, a SD Init is required */ BSP_SD_Init(); osMessagePut ( StorageEvent, MSDDISK_CONNECTION_EVENT, 0); } else { osMessagePut ( StorageEvent, MSDDISK_DISCONNECTION_EVENT, 0); }}
开发者ID:pierreroth64,项目名称:STM32Cube_FW_F4,代码行数:19,
示例10: BSP_SD_Init/** * @brief Initializes the SD card device. * @retval SD status */uint8_t BSP_SD_Init(void){ uint8_t sd_state = MSD_OK; /* PLLSAI is dedicated to LCD periph. Do not use it to get 48MHz*/ /* uSD device interface configuration */ uSdHandle.Instance = SDIO; uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B; uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_ENABLE; uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV; /* Configure IO functionalities for SD detect pin */ BSP_IO_Init(); /* Check if the SD card is plugged in the slot */ BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_INPUT_PU); if(BSP_SD_IsDetected() != SD_PRESENT) { return MSD_ERROR_SD_NOT_PRESENT; } /* Msp SD initialization */ BSP_SD_MspInit(&uSdHandle, NULL); /* HAL SD initialization */ if(HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK) { sd_state = MSD_ERROR; } /* Configure SD Bus width */ if(sd_state == MSD_OK) { /* Enable wide operation */ if(HAL_SD_WideBusOperation_Config(&uSdHandle, SDIO_BUS_WIDE_4B) != SD_OK) { sd_state = MSD_ERROR; } else { sd_state = MSD_OK; } } return sd_state;}
开发者ID:robbie-cao,项目名称:stm32f4-discovery,代码行数:54,
示例11: STORAGE_GetCapacity/** * @brief Returns the medium capacity. * @param lun: Logical unit number * @param block_num: Number of total block number * @param block_size: Block size * @retval Status (0: Ok / -1: Error) */int8_t STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_t *block_size){ HAL_SD_CardInfoTypedef info; int8_t ret = -1; if(BSP_SD_IsDetected() != SD_NOT_PRESENT) { BSP_SD_GetCardInfo(&info); *block_num = (info.CardCapacity)/STORAGE_BLK_SIZ - 1; *block_size = STORAGE_BLK_SIZ; ret = 0; } return ret;}
开发者ID:EarnestHein89,项目名称:STM32Cube_FW_F4,代码行数:22,
示例12: BSP_SD_Init/** * @brief Initializes the SD card device. * @retval SD status */uint8_t BSP_SD_Init(void){ uint8_t sd_state = MSD_OK; /* uSD device interface configuration */ uSdHandle.Instance = SDIO; uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B; uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_ENABLE; uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV; /* Msp SD Detect pin initialization */ BSP_SD_Detect_MspInit(&uSdHandle, NULL); /* Check if SD card is present */ if(BSP_SD_IsDetected() != SD_PRESENT) { return MSD_ERROR_SD_NOT_PRESENT; } /* Msp SD initialization */ BSP_SD_MspInit(&uSdHandle, NULL); /* HAL SD initialization */ if(HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK) { sd_state = MSD_ERROR; } /* Configure SD Bus width */ if(sd_state == MSD_OK) { /* Enable wide operation */ if(HAL_SD_WideBusOperation_Config(&uSdHandle, SDIO_BUS_WIDE_4B) != SD_OK) { sd_state = MSD_ERROR; } else { sd_state = MSD_OK; } } return sd_state;}
开发者ID:robbie-cao,项目名称:stm32f4-discovery,代码行数:52,
示例13: BSP_SD_Init/** * @brief Initializes the SD card device. * @param None * @retval SD status. */uint8_t BSP_SD_Init(void){ uint8_t SD_state = MSD_OK; /* uSD device interface configuration */ uSdHandle.Instance = SDIO; uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B; uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV; /* Configure IO functionalities for SD detect pin */ BSP_IO_Init(); /* Check if the SD card is plugged in the slot */ if(BSP_SD_IsDetected() != SD_PRESENT) { return MSD_ERROR; } /* HAL SD initialization */ SD_MspInit(); if(HAL_SD_Init(&uSdHandle, &SD_CardInfo) != SD_OK) { SD_state = MSD_ERROR; } /* Configure SD Bus width */ if(SD_state == MSD_OK) { /* Enable wide operation */ if(HAL_SD_WideBusOperation_Config(&uSdHandle, SDIO_BUS_WIDE_4B) != SD_OK) { SD_state = MSD_ERROR; } else { SD_state = MSD_OK; } } return SD_state;}
开发者ID:Bosvark,项目名称:STM32Cube_FW_F4_V1.1.0,代码行数:51,
示例14: HAL_GPIO_EXTI_Callback/** * @brief EXTI line detection callbacks. * @param GPIO_Pin: Specifies the pins connected EXTI line * @retval None */void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){ if(GPIO_Pin == MFX_IRQOUT_PIN) { if(BSP_SD_IsDetected()) { if(CAMERA_Configured == 0) { BSP_SD_Init(); } osMessagePut ( StorageEvent, MSDDISK_CONNECTION_EVENT, 0); } else { osMessagePut ( StorageEvent, MSDDISK_DISCONNECTION_EVENT, 0); } }}
开发者ID:451506709,项目名称:automated_machine,代码行数:23,
示例15: BSP_SD_Init/** * @brief Initializes the SD/SD communication. * @param None * @retval The SD Response: * - MSD_ERROR : Sequence failed * - MSD_OK : Sequence succeed */uint8_t BSP_SD_Init(void){ /* Configure IO functionalities for SD pin */ SD_IO_Init(); /* Check SD card detect pin */ if(BSP_SD_IsDetected()==SD_NOT_PRESENT) { SdStatus = SD_NOT_PRESENT; return MSD_ERROR; } else { SdStatus = SD_PRESENT; } /* SD initialized and set to SPI mode properly */ return (SD_GoIdleState());}
开发者ID:eleciawhite,项目名称:STM32Cube,代码行数:26,
示例16: SD_exti_demo/** * @brief SD Demo exti detection * @param None * @retval None */void SD_exti_demo (void){ uint32_t ITstatus = 0; SD_main_test(); if(BSP_SD_IsDetected() != SD_PRESENT) { BSP_SD_Init(); BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Not Connected", LEFT_MODE); } else { BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Connected ", LEFT_MODE); } BSP_SD_ITConfig(); while (1) { if (MfxExtiReceived == 1) { MfxExtiReceived = 0; ITstatus = BSP_IO_ITGetStatus(SD_DETECT_PIN); if (ITstatus) { SD_Detection(); } BSP_IO_ITClear(); } if(CheckForUserInput() > 0) { BSP_SD_DeInit(); return; } }}
开发者ID:451506709,项目名称:automated_machine,代码行数:45,
示例17: SD_Detection/** * @brief SD_Detection checks detection and writes msg on display * @param None * @retval None */void SD_Detection(void){ static uint8_t prev_status = 2; /* Check if the SD card is plugged in the slot */ if(BSP_SD_IsDetected() != SD_PRESENT) { if(prev_status != SD_NOT_PRESENT) { //BSP_SD_Init(); prev_status = SD_NOT_PRESENT; BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Not Connected", LEFT_MODE); } } else if (prev_status != SD_PRESENT) { prev_status = SD_PRESENT; BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Connected ", LEFT_MODE); }}
开发者ID:451506709,项目名称:automated_machine,代码行数:27,
示例18: Audio_ShowWavFiles/** * @brief Shows audio file (*.wav) on the root * @param None * @retval None */static uint8_t Audio_ShowWavFiles(void){ uint8_t i; uint8_t line_idx = 0; if((FileList.ptr > 0) && (BSP_SD_IsDetected())) { BSP_LCD_SetTextColor(LCD_COLOR_WHITE); LCD_UsrLog("audio file(s) [ROOT]:/n/n"); for( i = 0; i < FileList.ptr; i++) { line_idx++; if(line_idx > 9) { line_idx = 0; LCD_UsrLog("> Press [Key] To Continue./n"); /* KEY Button in polling */ while(BSP_PB_GetState(BUTTON_KEY) != RESET) { /* Wait for User Input */ } } LCD_DbgLog(" |__"); LCD_DbgLog((char *)FileList.file[i].name); LCD_DbgLog("/n"); } BSP_LCD_SetTextColor(LCD_COLOR_WHITE); LCD_UsrLog("/nEnd of files list./n"); return 0; } else { return 1; }}
开发者ID:ClintHaerinck,项目名称:STM32Cube_FW_F4,代码行数:42,
示例19: STORAGE_IsReady/** * @brief Checks whether the medium is ready. * @param lun: Logical unit number * @retval Status (0: Ok / -1: Error) */int8_t STORAGE_IsReady(uint8_t lun){ static int8_t prev_status = 0; int8_t ret = -1; if(BSP_SD_IsDetected() != SD_NOT_PRESENT) { if(prev_status < 0) { BSP_SD_Init(); prev_status = 0; } if(BSP_SD_GetStatus() == SD_TRANSFER_OK) { ret = 0; } } else if(prev_status == 0) { prev_status = -1; } return ret;}
开发者ID:EarnestHein89,项目名称:STM32Cube_FW_F4,代码行数:29,
示例20: BSP_SD_Init/** * @brief Initializes the SD card device. * @param None * @retval SD status */uint8_t BSP_SD_Init(void){ uint8_t SD_state = MSD_OK; /* Check if the SD card is plugged in the slot */ if (BSP_SD_IsDetected() != SD_PRESENT) { return MSD_ERROR; } SD_state = HAL_SD_Init(&hsd, &SDCardInfo);#ifdef BUS_4BITS if (SD_state == MSD_OK) { if (HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B) != SD_OK) { SD_state = MSD_ERROR; } else { SD_state = MSD_OK; } }#endif return SD_state;}
开发者ID:cosoria,项目名称:HavanaSDIO,代码行数:29,
示例21: main/** * @brief Main program * @param None * @retval None */int main(void){ uint32_t counter = 0, transparency = 0; uint8_t str[30]; uwInternelBuffer = (uint8_t *)0xC0260000; /* Enable the CPU Cache */ CPU_CACHE_Enable(); /* STM32F7xx HAL library initialization: - Configure the Flash ART accelerator on ITCM interface - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock to 200 MHz */ SystemClock_Config(); /* Configure LED3 */ BSP_LED_Init(LED3); /*##-1- Configure LCD ######################################################*/ LCD_Config(); /* Configure TAMPER Button */ BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO); BSP_SD_Init(); while(BSP_SD_IsDetected() != SD_PRESENT) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAtLine(8, (uint8_t*)" Please insert SD Card "); } BSP_LCD_Clear(LCD_COLOR_BLACK); /*##-2- Link the SD Card disk I/O driver ###################################*/ if(FATFS_LinkDriver(&SD_Driver, SD_Path) == 0) { /*##-3- Initialize the Directory Files pointers (heap) ###################*/ for (counter = 0; counter < MAX_BMP_FILES; counter++) { pDirectoryFiles[counter] = malloc(MAX_BMP_FILE_NAME); if(pDirectoryFiles[counter] == NULL) { /* Set the Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAtLine(8, (uint8_t*)" Cannot allocate memory "); while(1) { } } } /* Get the BMP file names on root directory */ ubNumberOfFiles = Storage_GetDirectoryBitmapFiles("/Media", pDirectoryFiles); if (ubNumberOfFiles == 0) { for (counter = 0; counter < MAX_BMP_FILES; counter++) { free(pDirectoryFiles[counter]); } BSP_LCD_DisplayStringAtLine(8, (uint8_t*)" No Bitmap files... "); while(1) { } } } else { /* FatFs Initialization Error */ Error_Handler(); } while(1) { counter = 0; while ((counter) < ubNumberOfFiles) { /* Step1 : Display on Foreground layer -------------------------------*/ /* Format the string */ sprintf ((char*)str, "Media/%-11.11s", pDirectoryFiles[counter]); if (Storage_CheckBitmapFile((const char*)str, &uwBmplen) == 0) { /* Format the string */ sprintf ((char*)str, "Media/%-11.11s", pDirectoryFiles[counter]); /* Set LCD foreground Layer *///.........这里部分代码省略.........
开发者ID:acrepina,项目名称:STM32F7_serverWEB,代码行数:101,
示例22: SD_demo/** * @brief SD Demo * @param None * @retval None */void SD_demo (void){ uint8_t SD_state = SD_RESPONSE_NO_ERROR; __IO uint8_t prev_status = 0; SD_SetHint(); SD_state = BSP_SD_Init(); /* Check if the SD card is plugged in the slot */ if(BSP_SD_IsDetected() == SD_PRESENT) { BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Connected ", LEFT_MODE); } else { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Not Connected", LEFT_MODE); } BSP_LCD_SetTextColor(LCD_COLOR_BLACK); if(SD_state != SD_RESPONSE_NO_ERROR) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD INITIALIZATION : FAIL.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD INITIALIZATION : OK.", LEFT_MODE); SD_state = BSP_SD_GetCardInfo(&CardInfo); if(SD_state != SD_RESPONSE_NO_ERROR) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD GET CARD INFO : FAIL.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD GET CARD INFO : OK.", LEFT_MODE); SD_state = BSP_SD_Erase(BLOCK_START_ADDR, (BLOCKSIZE * NUM_OF_BLOCKS)); /* Verify that SD card is ready to use after the Erase */ SD_state |= BSP_SD_GetStatus(); if(SD_state != SD_RESPONSE_NO_ERROR) { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD ERASE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD ERASE : OK.", LEFT_MODE); /* Fill the buffer to write */ Fill_Buffer(aTxBuffer, BUFFER_WORDS_SIZE, 0x22FF); SD_state = BSP_SD_WriteBlocks((uint32_t *)aTxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS); if(SD_state != SD_RESPONSE_NO_ERROR) { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD WRITE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD WRITE : OK.", LEFT_MODE); SD_state = BSP_SD_ReadBlocks((uint32_t *)aRxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS); if(SD_state != SD_RESPONSE_NO_ERROR) { BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD READ : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD READ : OK.", LEFT_MODE); if(Buffercmp(aTxBuffer, aRxBuffer, BUFFER_WORDS_SIZE) > 0) { BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD COMPARE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 190, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD TEST : OK.", LEFT_MODE); } } } } } } while (1) { /* Check if the SD card is plugged in the slot *///.........这里部分代码省略.........
开发者ID:eleciawhite,项目名称:STM32Cube,代码行数:101,
示例23: SD_demo/** * @brief SD Demo * @param None * @retval None */void SD_demo(void){ uint8_t SD_state = SD_OK; static uint8_t prev_status = 0; SD_SetHint(); SD_state = BSP_SD_Init(); if(SD_state != SD_OK) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD Initialization : FAIL.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD Initialization : OK.", LEFT_MODE); SD_state = BSP_SD_Erase(BLOCK_START_ADDR, (BLOCKSIZE * NUM_OF_BLOCKS)); if(SD_state != SD_OK) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD ERASE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD ERASE : OK.", LEFT_MODE); /* Fill the buffer to write */ Fill_Buffer(aTxBuffer, BUFFER_WORDS_SIZE, 0x22FF); SD_state = BSP_SD_WriteBlocks(aTxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS); if(SD_state != SD_OK) { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD WRITE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD WRITE : OK.", LEFT_MODE); SD_state = BSP_SD_ReadBlocks(aRxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS); if(SD_state != SD_OK) { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD READ : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD READ : OK.", LEFT_MODE); if(Buffercmp(aTxBuffer, aRxBuffer, BUFFER_WORDS_SIZE) > 0) { BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD COMPARE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD Test : OK.", LEFT_MODE); } } } } } /* Check if the SD card is plugged in the slot */ if(BSP_SD_IsDetected() == SD_PRESENT) { BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Connected ", LEFT_MODE); } else { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Not Connected", LEFT_MODE); } while (1) { /* Check if the SD card is plugged in the slot */ if(BSP_SD_IsDetected() != SD_PRESENT) { if(prev_status == 0) { BSP_SD_Init(); prev_status = 1; BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Not Connected", LEFT_MODE); } } else if (prev_status == 1) { BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Connected ", LEFT_MODE); prev_status = 0; } //.........这里部分代码省略.........
开发者ID:PaxInstruments,项目名称:STM32CubeF4,代码行数:101,
示例24: BSP_SD_Init/** * @brief Initializes the SD card device. * @param None * @retval SD status */uint8_t BSP_SD_Init(void) { uint8_t SD_state = MSD_OK; /* uSD device interface configuration */#if defined(SDIO) uSdHandle.Instance = SDIO; uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B; uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV;#elif defined(SDMMC1) uSdHandle.Instance = SDMMC1; uSdHandle.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING; uSdHandle.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE; uSdHandle.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE; uSdHandle.Init.BusWide = SDMMC_BUS_WIDE_1B; uSdHandle.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE; uSdHandle.Init.ClockDiv = SDMMC_TRANSFER_CLK_DIV; #else#error "NOT SUPPORTED!"#endif /* Init GPIO, DMA and NVIC */ SD_MspInit(); /* Check if the SD card is plugged in the slot */ if (BSP_SD_IsDetected() != SD_PRESENT) { return MSD_ERROR; } /* HAL SD initialization */ if (HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK) { SD_state = MSD_ERROR; } /* Configure SD Bus width */ if (SD_state == MSD_OK) { /* Enable wide operation */#if defined(SDIO_BUS_WIDE_4B)#if FATFS_SDIO_4BIT == 1 if (HAL_SD_WideBusOperation_Config(&uSdHandle, SDIO_BUS_WIDE_4B) != SD_OK) {#else if (HAL_SD_WideBusOperation_Config(&uSdHandle, SDIO_BUS_WIDE_1B) != SD_OK) { #endif#else#if FATFS_SDIO_4BIT == 1 if (HAL_SD_WideBusOperation_Config(&uSdHandle, SDMMC_BUS_WIDE_4B) != SD_OK) {#else if (HAL_SD_WideBusOperation_Config(&uSdHandle, SDMMC_BUS_WIDE_1B) != SD_OK) { #endif#endif SD_state = MSD_ERROR; } else { SD_state = MSD_OK; } } return SD_state;}/** * @brief Detects if SD card is correctly plugged in the memory slot or not. * @param None * @retval Returns if SD is detected or not */uint8_t BSP_SD_IsDetected(void) { return SDCARD_IsDetected();}/** * @brief Detects if SD card is write protected * @param None * @retval Returns if SD is write protected or not. */uint8_t BSP_SD_IsWriteProtected(void) { return !SDCARD_IsWriteEnabled();}/** * @brief Reads block(s) from a specified address in an SD card, in polling mode. * @param pData: Pointer to the buffer that will contain the data to transmit * @param ReadAddr: Address from where data is to be read * @param BlockSize: SD card data block size, that should be 512 * @param NumOfBlocks: Number of SD blocks to read * @retval SD status */uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) { if (HAL_SD_ReadBlocks(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) { return MSD_ERROR; } //.........这里部分代码省略.........
开发者ID:MaJerle,项目名称:stm32fxxx_hal_libraries,代码行数:101,
示例25: Save_Picture/** * @brief Saves the picture in microSD. * @param None * @retval None */void Save_Picture(void){ FRESULT res1, res2; /* FatFs function common result code */ uint32_t byteswritten = 0; /* File write count */ static uint32_t counter = 0; uint8_t str[30]; BSP_LCD_SetLayerVisible(1, ENABLE); BSP_LCD_SetColorKeying(1, LCD_COLOR_WHITE); /* Set foreground Layer */ BSP_LCD_SelectLayer(1); BSP_LCD_SetTextColor(LCD_COLOR_DARKRED); BSP_LCD_SetFont(&Font24); /* Initialize IOE */ BSP_IO_Init(); /* Check if the SD card is plugged in the slot */ if(BSP_SD_IsDetected() != SD_PRESENT) { BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize()-125), (uint8_t *)"SD Not Connected", RIGHT_MODE); BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize()-100), (uint8_t *)"Please inser SDCard", RIGHT_MODE); } else { BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize()-100), (uint8_t *)"Saving ..", RIGHT_MODE); /* Format the string */ sprintf((char *)str,"image_%d.bmp", (int)counter); /*##-1- Prepare the image to be saved ######################################*/ Prepare_Picture(); /*##-2- Create and Open a new bmp file object with write access ##########*/ if(f_open(&MyFile, (const char*)str, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK) { /* 'image.bmp' file Open for write Error */ Error_Handler(); } else { /*##-3- Write data to the BMP file #####################################*/ /* Write the BMP header */ if (BSP_LCD_GetXSize() == 640) { /* if ampire 640x480 LCD is used */ res1 = f_write(&MyFile, (uint32_t *)aBMPHeader1, 54, (void *)&byteswritten); } else { /* if ampire 480x272 LCD is used */ res1 = f_write(&MyFile, (uint32_t *)aBMPHeader2, 54, (void *)&byteswritten); } /* Write the bmp file */ res2 = f_write(&MyFile, (uint32_t *)CONVERTED_FRAME_BUFFER, ((BSP_LCD_GetYSize()-60)*(BSP_LCD_GetXSize()-60)*3), (void *)&byteswritten); if((res1 != FR_OK) || (res2 != FR_OK) || (byteswritten == 0)) { /* 'image' file Write or EOF Error */ Error_Handler(); } else { /*##-4- Close the open bmp file ######################################*/ f_close(&MyFile); /* Success of the demo: no error occurrence */ BSP_LED_On(LED1); BSP_LCD_SetTextColor(LCD_COLOR_DARKGREEN); BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize()-100), (uint8_t *)" Saved ", RIGHT_MODE); /* Select Layer 1 */ BSP_LED_Off(LED1); counter++; } } } /* Wait for 2s */ HAL_Delay(2000); /* Disable the Layer 2 */ BSP_LCD_SetLayerVisible(1, DISABLE); /* Clear the LCD Foreground layer */ BSP_LCD_Clear(LCD_COLOR_WHITE); BSP_LCD_SelectLayer(0);}
开发者ID:ClintHaerinck,项目名称:STM32Cube_FW_F4,代码行数:89,
示例26: Save_Picture/** * @brief Saves the picture in microSD. * @param None * @retval None */static void Save_Picture(void){ FRESULT res1 = FR_OK; FRESULT res2 = FR_OK; FRESULT res3 = FR_OK; /* FatFs function common result code */ uint32_t byteswritten = 0; /* File write count */ uint32_t bmpHeaderByteCnt = 0; uint32_t bmpFileInfoHeaderByteCnt = 0; uint32_t bmpFilePixelBytesCnt = 0; static uint32_t counter = 0; uint8_t str[30]; uint16_t tmp_size; /* Check if the SD card is plugged in the slot */ if(BSP_SD_IsDetected() != SD_PRESENT) { BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 20, (uint8_t*)"No SD card detected !!", RIGHT_MODE); Error_Handler(); } else { BSP_LCD_SetFont(&Font16); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 20, (uint8_t*)"Saving BMP to SD card", RIGHT_MODE); /* Format the string */ sprintf((char *)str, "image_%lu.bmp", counter); /* -- Prepare Bitmap file (BMP) header */ bmpFileHeader.bfType = 0x4D42; /* BMP file type */ /* Offset in bytes from start of file to first pixel data = size in bytes of complete BMP header */ /* careful the structure is padded on multiple of 32 bits by the compiler : the Padding should be removed */ bmpFileHeader.bOffBits = sizeof(BitMapFileHeader_Typedef) + sizeof(BitMapFileInfoHeader_Typedef) - sizeof(uint32_t) - sizeof(uint16_t); /* BMP complete file size is size of pad in RGB888 : 24bpp = 3 bytes per pixel + complete header size */ bmpFileHeader.bfSize = ((BSP_LCD_GetXSize() - 80) * (BSP_LCD_GetYSize() - 80) * RGB888_BYTE_PER_PIXEL); bmpFileHeader.bfSize += bmpFileHeader.bOffBits; bmpFileHeader.bfReserved1 = 0x0000; bmpFileHeader.bfReserved2 = 0x0000; bmpFileInfoHeader.biSize = 40; /* 40 bytes in bitmap info header */ bmpFileInfoHeader.biWidth = (BSP_LCD_GetXSize() - 80); bmpFileInfoHeader.biHeight = (BSP_LCD_GetYSize() - 80); bmpFileInfoHeader.biPlanes = 1; /* one single plane */ bmpFileInfoHeader.biBitCount = 24; /* RGB888 : 24 bits per pixel */ bmpFileInfoHeader.biCompression = 0; /* no compression */ /* This is number of pixel bytes in file : sizeX * sizeY * RGB888_BYTE_PER_PIXEL */ bmpFileInfoHeader.biSizeImage = ((BSP_LCD_GetXSize() - 80) * (BSP_LCD_GetYSize() - 80) * RGB888_BYTE_PER_PIXEL); bmpFileInfoHeader.biXPelsPerMeter = 0; /* not used */ bmpFileInfoHeader.biYPelsPerMeter = 0; /* not used */ bmpFileInfoHeader.biClrUsed = 0; /* not used */ bmpFileInfoHeader.biClrImportant = 0; /* not used */ /* -- End Prepare Bitmap file (BMP) header */ /*##-1- Prepare the image to be saved ####################################*/ Prepare_Picture(); /* Disable the LTDC to avoid charging the bandwidth for nothing while the BMP file is */ /* written to SD card */ LTDC_Operation(0); /*##-2- Create and Open a new bmp file object with write access ##########*/ if(f_open(&MyFile, (const char*)str, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK) { /* 'image.bmp' file Open for write Error */ BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 20, (uint8_t*)" BMP File Creation Error !!", RIGHT_MODE); Error_Handler(); } else { /*##-3- Write data to the BMP file #####################################*/ /* Write the BMP header step 1 : first write BMP header : all but padding is written to file */ res1 = f_write(&MyFile, (uint16_t *)&(bmpFileHeader.bfType), sizeof(uint16_t), (void *)&bmpHeaderByteCnt); byteswritten += bmpHeaderByteCnt; /* LSB of size in bytes of BMP file */ tmp_size = (uint16_t)(bmpFileHeader.bfSize & 0x0000FFFF); res1 = f_write(&MyFile, (uint16_t *)&(tmp_size), sizeof(uint16_t), (void *)&bmpHeaderByteCnt); byteswritten += bmpHeaderByteCnt; /* MSB of size in bytes of BMP file */ tmp_size = (uint16_t)((bmpFileHeader.bfSize & 0xFFFF0000) >> 16); res1 = f_write(&MyFile, (uint16_t *)&(tmp_size), sizeof(uint16_t), (void *)&bmpHeaderByteCnt);//.........这里部分代码省略.........
开发者ID:pierreroth64,项目名称:STM32Cube_FW_F4,代码行数:101,
示例27: main/** * @brief Main program * @param None * @retval None */int main(void){ uint32_t counter = 0; uint8_t str[30]; uwInternelBuffer = (uint8_t *)0xC0260000; /* Enable the CPU Cache */ CPU_CACHE_Enable(); /* STM32F7xx HAL library initialization: - Configure the Flash ART accelerator on ITCM interface - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock to 200 MHz */ SystemClock_Config(); /* Configure LED3 */ BSP_LED_Init(LED3); /*##-1- Configure LCD ######################################################*/ LCD_Config(); BSP_SD_Init(); while(BSP_SD_IsDetected() != SD_PRESENT) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAtLine(8, (uint8_t*)" Please insert SD Card "); } BSP_LCD_Clear(LCD_COLOR_BLACK); /*##-2- Link the SD Card disk I/O driver ###################################*/ if(FATFS_LinkDriver(&SD_Driver, SD_Path) != 0) { Error_Handler(); } else { /*##-3- Initialize the Directory Files pointers (heap) ###################*/ for (counter = 0; counter < MAX_BMP_FILES; counter++) { pDirectoryFiles[counter] = malloc(MAX_BMP_FILE_NAME); if(pDirectoryFiles[counter] == NULL) { /* Set the Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAtLine(8, (uint8_t*)" Cannot allocate memory "); while(1) { } } } /*##-4- Display Background picture #######################################*/ /* Select Background Layer */ BSP_LCD_SelectLayer(0); /* Register the file system object to the FatFs module */ if(f_mount(&SD_FatFs, (TCHAR const*)SD_Path, 0) != FR_OK) { /* FatFs Initialization Error */ /* Set the Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAtLine(8, (uint8_t*)" FatFs Initialization Error "); } else { /* Open directory */ if (f_opendir(&directory, (TCHAR const*)"/BACK") != FR_OK) { /* Set the Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAtLine(8, (uint8_t*)" Open directory.. fails "); while(1) { } } } if (Storage_CheckBitmapFile("BACK/image.bmp", &uwBmplen) == 0) { /* Format the string */ Storage_OpenReadFile(uwInternelBuffer, "BACK/image.bmp"); /* Write bmp file on LCD frame buffer */ BSP_LCD_DrawBitmap(0, 0, uwInternelBuffer); }//.........这里部分代码省略.........
开发者ID:acrepina,项目名称:STM32F7_serverWEB,代码行数:101,
注:本文中的BSP_SD_IsDetected函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ BSP_TS_GetState函数代码示例 C++ BSP_SD_Init函数代码示例 |