这篇教程C++ Fill_Buffer函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Fill_Buffer函数的典型用法代码示例。如果您正苦于以下问题:C++ Fill_Buffer函数的具体用法?C++ Fill_Buffer怎么用?C++ Fill_Buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Fill_Buffer函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: UsartDMA_Sendvoid UsartDMA_Send(INT8U *data){ if(usart_reset_key < 5) { Fill_Buffer(TxBuffer_dma_save[tx_count], 24, data); tx_count++; if (tx_count > 9) tx_count = 0; if(data_complete) { Fill_Buffer(TxBuffer_dma, 24, TxBuffer_dma_save[tx_now_send]); data_complete = FALSE; DMA_Cmd(USARTx_TX_DMA_STREAM, ENABLE); } }}
开发者ID:wangxubo1988,项目名称:Center_System,代码行数:15,
示例2: mainint main(void){ uint8_t i; printf("SBN1 test 5 /r/n"); // lock 0xAB 01000 Fill_Buffer(0x0A, 0x53, 0x42, 0x4E, 0x31, 0x00, 0x03, 0xB4, 0x07, 0xAB, 0x02); SBN1_Handle_Reveived(); // lock 0xAB 00111 Fill_Buffer(0x0A, 0x53, 0x42, 0x4E, 0x31, 0x01, 0x03, 0xCE, 0x07, 0xAB, 0x1C); SBN1_Handle_Reveived(); return 0;}
开发者ID:BHFaction,项目名称:SanBot,代码行数:15,
示例3: SD_SingleBlockTest/** * @brief Tests the SD card Single Blocks operations. * @param None * @retval None */static void SD_SingleBlockTest(void){ SD_Error status; /*---------------Block Read/Write----------------*/ /* Fill the buffer to send */ Fill_Buffer(aBuffer_Block_Tx, BLOCK_SIZE, 0x320F); /* Write Block of 512 bytes on address 0 */ status = SD_WriteBlock(aBuffer_Block_Tx, 0x00, BLOCK_SIZE); /* check if the Transfer finished */ status = SD_WaitWriteOperation(); while(SD_GetStatus() != SD_TRANSFER_OK); if(status == SD_OK) { /* Read Block of 512 bytes on address 0 */ status = SD_ReadBlock(aBuffer_Block_Rx, 0x00, BLOCK_SIZE); /* check if the Transfer finished */ status = SD_WaitReadOperation(); while(SD_GetStatus() != SD_TRANSFER_OK); } /* Check the correctness of written data */ if(status == SD_OK) { TransferStatus1 = Buffercmp(aBuffer_Block_Tx, aBuffer_Block_Rx,BLOCK_SIZE); } if(TransferStatus1 == PASSED) printf("SD single block test passed!/n/r");}
开发者ID:jssmile,项目名称:Plotter,代码行数:35,
示例4: SD_MultiBlockTest/** * @brief Tests the SD card Multiple Blocks operations. * @param None * @retval None */static void SD_MultiBlockTest(void){ SD_Error status; /* Fill the buffer to send */ Fill_Buffer(aBuffer_MultiBlock_Tx, MULTI_BUFFER_SIZE, 0x0); /* Write Multiple Block of many bytes on address 0 */ status = SD_WriteMultiBlocksFIXED(aBuffer_MultiBlock_Tx, 0, BLOCK_SIZE, NUMBER_OF_BLOCKS); /* check if the Transfer finished */ status = SD_WaitWriteOperation(); while(SD_GetStatus() != SD_TRANSFER_OK); if(status == SD_OK) { /* Read Block of many bytes from address 0 */ status = SD_ReadMultiBlocksFIXED(aBuffer_MultiBlock_Rx, 0, BLOCK_SIZE, NUMBER_OF_BLOCKS); /* check if the Transfer finished */ status = SD_WaitReadOperation(); while(SD_GetStatus() != SD_TRANSFER_OK); } /* Check the correctness of written data */ if(status == SD_OK) { TransferStatus2 = Buffercmp(aBuffer_MultiBlock_Tx, aBuffer_MultiBlock_Rx,MULTI_BUFFER_SIZE); } if(TransferStatus2 == PASSED) printf("SD Multiple block test passed!/n/r");}
开发者ID:jssmile,项目名称:Plotter,代码行数:36,
示例5: Sram_thread_entryvoid Sram_thread_entry(void* parameter){ rt_tick_t t1,t2; SRAM_Init(); Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F); //DMA_Config();// while(flag)// {// rt_thread_delay(1);// } rt_sem_take(&rt_sram_sem, RT_WAITING_FOREVER); while(flag1) { int fd; //int i=1024; fd = open("/ud/text.txt", O_WRONLY | O_CREAT,0); if (fd >= 0) { t1 = rt_tick_get();// while(i>0)// { write(fd, RAM_Buffer, sizeof(RAM_Buffer));// i--;// } t2 = rt_tick_get(); rt_kprintf("%d/n/r",t2-t1); close(fd); } rt_thread_delay(100); //SRAM_ReadBuffer(aTxBuffer,0,BUFFER_SIZE); } while(1); //Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F); }
开发者ID:XHelaoshi,项目名称:USER,代码行数:34,
示例6: SDRAM_demo/** * @brief SDRAM Demo * @param None * @retval None */void SDRAM_demo (void){ SDRAM_SetHint(); /* SDRAM device configuration */ if(BSP_SDRAM_Init() != SDRAM_OK) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SDRAM Initialization : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SDRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SDRAM Initialization : OK.", LEFT_MODE); } /* Fill the buffer to write */ Fill_Buffer(sdram_aTxBuffer, SDRAM_BUFFER_SIZE, 0xA244250F); /* Write data to the SDRAM memory */ if(BSP_SDRAM_WriteData(SDRAM_WRITE_READ_ADDR + WRITE_READ_ADDR_OFFSET, sdram_aTxBuffer, SDRAM_BUFFER_SIZE) != SDRAM_OK) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SDRAM WRITE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SDRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SDRAM WRITE : OK.", LEFT_MODE); } /* Read back data from the SDRAM memory */ if(BSP_SDRAM_ReadData(SDRAM_WRITE_READ_ADDR + WRITE_READ_ADDR_OFFSET, sdram_aRxBuffer, SDRAM_BUFFER_SIZE) != SDRAM_OK) { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SDRAM READ : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SDRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SDRAM READ : OK.", LEFT_MODE); } if(Buffercmp(sdram_aTxBuffer, sdram_aRxBuffer, SDRAM_BUFFER_SIZE) > 0) { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SDRAM COMPARE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SDRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SDRAM Test : OK.", LEFT_MODE); } while (1) { if(CheckForUserInput() > 0) { BSP_SDRAM_DeInit(); return; } }}
开发者ID:Joe-Merten,项目名称:Stm32-Tools-Evaluation,代码行数:64,
示例7: main/** * @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_stm32f40_41xxx.s/startup_stm32f427_437xx.s/ startup_stm32f429_439xx.s/startup_stm32f401xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ /* Initialize LEDs on STM324x9I-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); /* Configure the FMC interface : SDRAM */ FMC_Config(); /* Fill the buffer to write */ Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0x250F); /* Write data to the SDRAM memory */ for (uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++) { *(__IO uint32_t*) (SDRAM_BANK_ADDR + WRITE_READ_ADDR + 4*uwIndex) = aTxBuffer[uwIndex]; } /* Read back data from the SDRAM memory */ for (uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++) { aRxBuffer[uwIndex] = *(__IO uint32_t*) (SDRAM_BANK_ADDR + WRITE_READ_ADDR + 4*uwIndex); } /* Check the SDRAM memory content correctness */ for (uwIndex = 0; (uwIndex < BUFFER_SIZE) && (uwWriteReadStatus == 0); uwIndex++) { if (aRxBuffer[uwIndex] != aTxBuffer[uwIndex]) { uwWriteReadStatus++; } } if (uwWriteReadStatus) { /* KO */ /* Turn on LD2 */ STM_EVAL_LEDOn(LED2); } else { /* OK */ /* Turn on LD1 */ STM_EVAL_LEDOn(LED1); } while (1) { } }
开发者ID:CristianKrieger,项目名称:InterfazAdquisicionNTSC,代码行数:64,
示例8: main/** * @brief Main program. * @param None * @retval None */int main(void){ /* System Clocks Configuration */ RCC_Configuration(); /* Initialize Leds mounted on STM3210X-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); /* Write/read to/from FSMC SRAM memory *************************************/ /* Enable the FSMC Clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); /* Configure FSMC Bank1 NOR/SRAM2 */ FSMC_NOR_Init(); /* Read NOR memory ID */ FSMC_NOR_ReadID(&NOR_ID); FSMC_NOR_ReturnToReadMode(); /* Erase the NOR memory block to write on */ FSMC_NOR_EraseBlock(WRITE_READ_ADDR); /* Write data to FSMC NOR memory */ /* Fill the buffer to send */ Fill_Buffer(TxBuffer, BUFFER_SIZE, 0x3210); FSMC_NOR_WriteBuffer(TxBuffer, WRITE_READ_ADDR, BUFFER_SIZE); /* Read data from FSMC NOR memory */ FSMC_NOR_ReadBuffer(RxBuffer, WRITE_READ_ADDR, BUFFER_SIZE); /* Read back NOR memory and check content correctness */ for (Index = 0x00; (Index < BUFFER_SIZE) && (WriteReadStatus == 0); Index++) { if (RxBuffer[Index] != TxBuffer[Index]) { WriteReadStatus = Index + 1; } } if (WriteReadStatus == 0) { /* OK */ /* Turn on LED1 */ STM_EVAL_LEDOn(LED1); } else { /* KO */ /* Turn on LED2 */ STM_EVAL_LEDOn(LED2); } while (1) { }}
开发者ID:qiubailiang,项目名称:src_docs,代码行数:63,
示例9: main/** * @brief Main program * @param None * @retval None */int main(void){ /* Configure the MPU attributes as Write Through */ MPU_Config(); /* Enable the CPU Cache */ CPU_CACHE_Enable(); /* STM32F7xx HAL library initialization: - Configure the Flash ART accelerator on ITCM interface - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization */ HAL_Init(); /* Configure LED1 and LED3 */ BSP_LED_Init(LED1); BSP_LED_Init(LED3); /* Configure the system clock to 200 MHz */ /* This function will be executed from SDRAM */ SystemClock_Config(); /*##-1- Fill the buffer in the SDRAM device ##########################################*/ Fill_Buffer(aTable, 1024, 0); /*##-2- Read address of the buffer and stack pointer address ########################*/ uwTabAddr = (uint32_t)aTable; /* should be above 0x60000000 */ /* Get main stack pointer value */ MSPValue = __get_MSP(); /* should be above 0x60000000 */ /*##-3- Activate LEDs pending on read values ########################################*/ if ((uwTabAddr >= SDRAM_ADDRESS) && (MSPValue >= SDRAM_ADDRESS)) { BSP_LED_On(LED1); } else { /* Toggle LED3 in an infinite loop */ while (1) { BSP_LED_Toggle(LED3); /* Insert delay 100 ms */ HAL_Delay(100); } } /* Infinite loop */ while (1) { }}
开发者ID:MrZANE42,项目名称:verisure1512,代码行数:62,
示例10: main/** * @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_stm32f10x_xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f10x.c file */ /* Initialize Leds mounted on STM3210X-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); /* Write/read to/from FSMC SRAM memory *************************************/ /* Enable the FSMC Clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); /* Configure FSMC Bank1 NOR/SRAM3 */ SRAM_Init(); /* Write data to FSMC SRAM memory */ /* Fill the buffer to send */ Fill_Buffer(TxBuffer, BUFFER_SIZE, 0x3212); SRAM_WriteBuffer(TxBuffer, WRITE_READ_ADDR, BUFFER_SIZE); /* Read data from FSMC SRAM memory */ SRAM_ReadBuffer(RxBuffer, WRITE_READ_ADDR, BUFFER_SIZE); /* Read back SRAM memory and check content correctness */ for (Index = 0x00; (Index < BUFFER_SIZE) && (WriteReadStatus == 0); Index++) { if (RxBuffer[Index] != TxBuffer[Index]) { WriteReadStatus = Index + 1; } } if (WriteReadStatus == 0) { /* OK */ /* Turn on LED1 */ STM_EVAL_LEDOn(LED1); } else { /* KO */ /* Turn on LED2 */ STM_EVAL_LEDOn(LED2); } while (1) { }}
开发者ID:Dzenik,项目名称:QuadVolucer,代码行数:60,
示例11: main/** * @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 on EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); /* Initialize the SRAM memory */ SRAM_Init(); /* Fill the buffer to send */ Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0x250F); /* Write data to the SRAM memory */ SRAM_WriteBuffer(aTxBuffer, WRITE_READ_ADDR, BUFFER_SIZE); /* Read back data from the SRAM memory */ SRAM_ReadBuffer(aRxBuffer, WRITE_READ_ADDR, BUFFER_SIZE); /* Check the SRAM memory content correctness */ for (uwIndex = 0; (uwIndex < BUFFER_SIZE) && (uwWriteReadStatus_SRAM == 0); uwIndex++) { if (aRxBuffer[uwIndex] != aTxBuffer[uwIndex]) { uwWriteReadStatus_SRAM++; } } if (uwWriteReadStatus_SRAM) { /* KO */ /* Turn on LD2 */ STM_EVAL_LEDOn(LED2); } else { /* OK */ /* Turn on LD1 */ STM_EVAL_LEDOn(LED1); } while (1) { } }
开发者ID:BlockWorksCo,项目名称:Platform,代码行数:59,
示例12: main/** * @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_stm32f0xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f0xx.c file */ /* Initialize Leds mounted on STM320518-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); /* Initializes the SD/SPI communication */ Status = SD_Init(); /* If SD is responding */ if (Status == SD_RESPONSE_NO_ERROR) { /* Fill the buffer to send */ Fill_Buffer(Buffer_Block_Tx, BUFFERSIZE, 0x0); /* Write block of 512 bytes on address 0 */ Status = SD_WriteBlock(Buffer_Block_Tx, 0, BUFFERSIZE); /* Read block of 512 bytes from address 0 */ Status = SD_ReadBlock(Buffer_Block_Rx, 0, BUFFERSIZE); /* Check the corectness of written dada */ TransferStatus = Buffercmp(Buffer_Block_Tx, Buffer_Block_Rx, BUFFERSIZE); if (TransferStatus == PASSED) { /* OK: Turn on LD1 */ STM_EVAL_LEDOn(LED1); } else { /* Error: Turn on LD2 */ STM_EVAL_LEDOn(LED2); } } else { /* Error: Turn on LD2 */ STM_EVAL_LEDOn(LED2); } while (1) { } }
开发者ID:Qasemt,项目名称:STM32F0xx_StdPeriph_Lib_V1.0.0,代码行数:58,
示例13: SD_SingleBlockTest/** * @brief Tests the SD card Single Blocks operations. * @param None * @retval None */void SD_SingleBlockTest(void){ TestStatus TransferStatus1 = FAILED; /* Fill the buffer to send */ Fill_Buffer(Buffer_Block_Tx, BLOCK_SIZE, 0x320F); /* Write block of 512 bytes on address 0 */ Status = SDC_WriteBlock(Buffer_Block_Tx, 0x00, BLOCK_SIZE); /* Check if the Transfer is finished */ Status = SDC_WaitWriteOperation(); while(SDC_GetStatus() != SD_TRANSFER_OK); if (Status == SD_OK) { /* Read block of 512 bytes from address 0 */ Status = SDC_ReadBlock(Buffer_Block_Rx, 0x00, BLOCK_SIZE); /* Check if the Transfer is finished */ Status = SDC_WaitReadOperation(); while(SDC_GetStatus() != SD_TRANSFER_OK); } else { printf("SD_SingleBlockTest:SDC_WriteBlock failed with %d/n",Status); } /* Check the correctness of written data */ if (Status == SD_OK) { TransferStatus1 = Buffercmp(Buffer_Block_Tx, Buffer_Block_Rx, / BLOCK_SIZE); if(TransferStatus1 == PASSED) { printf("SD_SingleBlockTest() passed/n"); } else { printf("SD_SingleBlockTest():Buffercmp failed/n"); } } else { printf("SD_SingleBlockTest:SDC_ReadBlock failed with %d/n",Status); } }
开发者ID:lilpako,项目名称:ministm32-bsp,代码行数:54,
示例14: SD_MultiBlockTest/** * @brief Tests the SD card Multiple Blocks operations. * @param None * @retval None */void SD_MultiBlockTest(void){ TestStatus TransferStatus2 = FAILED; /* Fill the buffer to send */ Fill_Buffer(Buffer_MultiBlock_Tx, MULTI_BUFFER_SIZE, 0x0); /* Write multiple block of many bytes on address 0 */ Status = SDC_WriteMultiBlocks(Buffer_MultiBlock_Tx, 0x00, / BLOCK_SIZE, NUMBER_OF_BLOCKS); /* Check if the Transfer is finished */ Status = SDC_WaitWriteOperation(); while(SDC_GetStatus() != SD_TRANSFER_OK); if (Status == SD_OK) { /* Read block of many bytes from address 0 */ Status = SDC_ReadMultiBlocks(Buffer_MultiBlock_Rx, 0x00, / BLOCK_SIZE, NUMBER_OF_BLOCKS); /* Check if the Transfer is finished */ Status = SDC_WaitReadOperation(); while(SDC_GetStatus() != SD_TRANSFER_OK); } else { printf("SD_MultiBlockTest:SDC_WriteMultiBlock failed/n"); } /* Check the correctness of written data */ if (Status == SD_OK) { TransferStatus2 = Buffercmp(Buffer_MultiBlock_Tx, / Buffer_MultiBlock_Rx, MULTI_BUFFER_SIZE); if(TransferStatus2 == PASSED) { printf("SD_MultiBlockTest passed/n"); } else { printf("SD_MultiBlockTest:Buffercmp failed/n"); } } else { printf("SD_MultiBlockTest:SDC_ReadMultiBlock failed/n"); } }
开发者ID:lilpako,项目名称:ministm32-bsp,代码行数:54,
示例15: mainint main(void){ uint8_t i; printf("SBN1 test 2 /r/n"); Fill_Buffer(0x09, 0x53, 0x42, 0x4E, 0x31, 0x00, 0x02, 0x04, 0x03, 0x01); SBN1_Handle_Reveived(); for(i = 0x00; i < 0xff; i++) { SBN1_Loop(); } return 0;}
开发者ID:BHFaction,项目名称:SanBot,代码行数:15,
示例16: main/** * @brief Main program * @param None * @retval None */int main(void){ /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization: global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock to 180 MHz */ SystemClock_Config(); /* Configure LED1 and LED2 */ BSP_LED_Init(LED1); BSP_LED_Init(LED3); /*##-1- Fill the buffer in the SRAM device ##########################################*/ Fill_Buffer(aTable, 1024, 0); /*##-2- Read address of the buffer and stack pointer address ########################*/ uwTabAddr = (uint32_t)aTable; /* should be above 0x64000000 */ /* Get main stack pointer value */ MSPValue = __get_MSP(); /* should be above 0x64000000 */ /*##-3- Activate LEDs pending on read values ########################################*/ if ((uwTabAddr >= SRAM_ADDRESS) && (MSPValue >= SRAM_ADDRESS)) { BSP_LED_On(LED1); } else { BSP_LED_On(LED3); } /* Infinite loop */ while (1) { }}
开发者ID:pierreroth64,项目名称:STM32Cube_FW_F4,代码行数:49,
示例17: SD_SingleBlockTest/** * @brief Tests the SD card Single Blocks operations. * @param None * @retval None */void SD_SingleBlockTest(void){ /*------------------- Block Read/Write --------------------------*/ /* Fill the buffer to send */ Fill_Buffer(Buffer_Block_Tx, BLOCK_SIZE, 0x320F); if (Status == SD_OK) { /* Write block of 512 bytes on address 0 */ Status = SD_WriteBlock(Buffer_Block_Tx, 0x00, BLOCK_SIZE); /* Check if the Transfer is finished */ Status = SD_WaitWriteOperation(); while(SD_GetStatus() != SD_TRANSFER_OK); } if (Status == SD_OK) { /* Read block of 512 bytes from address 0 */ Status = SD_ReadBlock(Buffer_Block_Rx, 0x00, BLOCK_SIZE); /* Check if the Transfer is finished */ Status = SD_WaitReadOperation(); while(SD_GetStatus() != SD_TRANSFER_OK); } /* Check the correctness of written data */ if (Status == SD_OK) { TransferStatus1 = Buffercmp(Buffer_Block_Tx, Buffer_Block_Rx, BLOCK_SIZE); } if(TransferStatus1 == PASSED) { STM_EVAL_LEDOn(LED2); LCD_DisplayStringLine(LCD_LINE_2, "Passed"); } else { STM_EVAL_LEDOff(LED2); STM_EVAL_LEDOn(LED4); LCD_DisplayStringLine(LCD_LINE_2, "failed"); }}
开发者ID:ahmadrezahossiny,项目名称:stm32f4_extboard_periph_examples,代码行数:47,
示例18: SD_MultiBlockTest/** * @brief Tests the SD card Multiple Blocks operations. * @param None * @retval None */void SD_MultiBlockTest(void){ /*--------------- Multiple Block Read/Write ---------------------*/ /* Fill the buffer to send */ Fill_Buffer(Buffer_MultiBlock_Tx, MULTI_BUFFER_SIZE, 0x0); if (Status == SD_OK) { /* Write multiple block of many bytes on address 0 */ Status = SD_WriteMultiBlocks(Buffer_MultiBlock_Tx, 0x00, BLOCK_SIZE, NUMBER_OF_BLOCKS); /* Check if the Transfer is finished */ Status = SD_WaitWriteOperation(); while(SD_GetStatus() != SD_TRANSFER_OK); } if (Status == SD_OK) { /* Read block of many bytes from address 0 */ Status = SD_ReadMultiBlocks(Buffer_MultiBlock_Rx, 0x00, BLOCK_SIZE, NUMBER_OF_BLOCKS); /* Check if the Transfer is finished */ Status = SD_WaitReadOperation(); while(SD_GetStatus() != SD_TRANSFER_OK); } /* Check the correctness of written data */ if (Status == SD_OK) { TransferStatus2 = Buffercmp(Buffer_MultiBlock_Tx, Buffer_MultiBlock_Rx, MULTI_BUFFER_SIZE); } if(TransferStatus2 == PASSED) { STM_EVAL_LEDOn(LED3); LCD_DisplayStringLine(LCD_LINE_2, "Passed"); } else { STM_EVAL_LEDOff(LED3); STM_EVAL_LEDOn(LED4); LCD_DisplayStringLine(LCD_LINE_2, "failed"); }}
开发者ID:ahmadrezahossiny,项目名称:stm32f4_extboard_periph_examples,代码行数:47,
示例19: SD_SingleBlockTest/** * @brief Tests the SD card Single Blocks operations. * @param None * @retval None */void SD_SingleBlockTest(void){ /*------------------- Block Read/Write --------------------------*/ /* Fill the buffer to send */ Fill_Buffer(Buffer_Block_Tx, BLOCK_SIZE, 0x320F); if (Status == SD_OK) { /* Write block of 512 bytes on address 0 */ Status = SD_WriteBlock(Buffer_Block_Tx, 0x00, BLOCK_SIZE); /* Check if the Transfer is finished */ Status = SD_WaitWriteOperation(); while(SD_GetStatus() != SD_TRANSFER_OK); } if (Status == SD_OK) { /* Read block of 512 bytes from address 0 */ Status = SD_ReadBlock(Buffer_Block_Rx, 0x00, BLOCK_SIZE); /* Check if the Transfer is finished */ Status = SD_WaitReadOperation(); while(SD_GetStatus() != SD_TRANSFER_OK); } /* Check the correctness of written data */ if (Status == SD_OK) { TransferStatus1 = Buffercmp(Buffer_Block_Tx, Buffer_Block_Rx, BLOCK_SIZE); } if(TransferStatus1 == PASSED) { xprintf("Block test passed/n"); } else { xprintf("Block test failed/n"); }}
开发者ID:art1,项目名称:FloatSat-Project-G9,代码行数:44,
示例20: BSP_TEST_SDIOuint8_t BSP_TEST_SDIO(void){ uint8_t t_status = 0; /*-------------------------- SD Init ----------------------------- */ BSP_SDCARD_ENABLE(); Status = SD_Init(); if (Status == SD_OK) { /*----------------- Read CSD/CID MSD registers ------------------*/ Status = SD_GetCardInfo(&SDCardInfo); } if (Status == SD_OK) { /*----------------- Select Card --------------------------------*/ Status = SD_SelectDeselect((uint32_t) (SDCardInfo.RCA << 16)); } if (Status == SD_OK) { Status = SD_EnableWideBusOperation(SDIO_BusWide_4b); } /*------------------- Block Erase -------------------------------*/ if (Status == SD_OK) { /* Erase NumberOfBlocks Blocks of WRITE_BL_LEN(512 Bytes) */ Status = SD_Erase(0x00, (SDIO_BLOCK_SIZE * SDIO_NB_BLOCK)); } /* Set Device Transfer Mode to DMA */ if (Status == SD_OK) { Status = SD_SetDeviceMode(SD_DMA_MODE); } if (Status == SD_OK) { Status = SD_ReadMultiBlocks(0x00, Buffer_MultiBlock_Rx, SDIO_BLOCK_SIZE, SDIO_NB_BLOCK); } if (Status == SD_OK) { t_status = eBuffercmp(Buffer_MultiBlock_Rx, SDIO_MULTIWSIZE); } /*------------------- Block Read/Write --------------------------*/ /* Fill the buffer to send */ Fill_Buffer(Buffer_Block_Tx, SDIO_BUFFERW_SIZE, 0xFFFF); if (Status == SD_OK) { /* Write block of 512 bytes on address 0 */ Status = SD_WriteBlock(0x00, Buffer_Block_Tx, SDIO_BLOCK_SIZE); } if (Status == SD_OK) { /* Read block of 512 bytes from address 0 */ Status = SD_ReadBlock(0x00, Buffer_Block_Rx, SDIO_BLOCK_SIZE); } if (Status == SD_OK) { /* Check the corectness of written dada */ t_status &= Buffercmp(Buffer_Block_Tx, Buffer_Block_Rx, SDIO_BUFFERW_SIZE); } BSP_SDCARD_DISABLE(); return t_status;}
开发者ID:ozwin,项目名称:erts-project,代码行数:75,
示例21: QSPI_demo/*** @brief QSPI Demo* @param None* @retval None*/void QSPI_demo (void){ uint8_t status; QSPI_SetHint(); /*##-1- Configure the QSPI device ##########################################*/ /* QSPI device configuration */ status = BSP_QSPI_Init(); if (status == QSPI_NOT_SUPPORTED) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t*)"QSPI Initialization : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"QSPI Test Aborted.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"Check the hardware configuration :", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)" refer to the UM of the board", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 175, (uint8_t*)" for the hardware modifications", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 190, (uint8_t*)" to connect the QSPI memory", LEFT_MODE); } else if (status == QSPI_ERROR) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t*)"QSPI Initialization : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"QSPI Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 100, (uint8_t*)"QSPI Initialization : OK.", LEFT_MODE); /*##-2- Read & check the QSPI info #######################################*/ /* Clear the structure */ QspiInfo.FlashSize = (uint32_t)0x00; QspiInfo.EraseSectorSize = (uint32_t)0x00; QspiInfo.EraseSectorsNumber = (uint32_t)0x00; QspiInfo.ProgPageSize = (uint32_t)0x00; QspiInfo.ProgPagesNumber = (uint32_t)0x00; QspiInfo.ManufID = (uint8_t)0x00; /* Read the QSPI memory info by filling QSPIInfo struct */ BSP_QSPI_GetInfo(&QspiInfo); /* Test the correctness */ if (CompareInfo() !=QSPI_OK) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"QSPI GET INFO : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 130, (uint8_t*)"QSPI Test Aborted.", LEFT_MODE); } else { if (QspiInfo.ManufID == QSPI_S25FL512S) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"QSPI GET INFO : OK. S25FL512S detected ", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"QSPI GET INFO : OK. N25Q512A detected ", LEFT_MODE); } /*##-3- Erase QSPI memory ################################################*/ if(BSP_QSPI_Erase_Block(WRITE_READ_ADDR) != QSPI_OK) { BSP_LCD_DisplayStringAt(20, 130, (uint8_t*)"QSPI ERASE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"QSPI Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 130, (uint8_t*)"QSPI ERASE : OK. ", LEFT_MODE); /*##-4- QSPI memory read/write access #################################*/ /* Fill the buffer to write */ Fill_Buffer(qspi_aTxBuffer, BUFFER_SIZE, 0xD20F); /* Write data to the QSPI memory */ if(BSP_QSPI_Write(qspi_aTxBuffer, WRITE_READ_ADDR, BUFFER_SIZE) != QSPI_OK) { BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"QSPI WRITE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)"QSPI Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"QSPI WRITE : OK. ", LEFT_MODE); /* Read back data from the QSPI memory */ if(BSP_QSPI_Read(qspi_aRxBuffer, WRITE_READ_ADDR, BUFFER_SIZE) != QSPI_OK) { BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)"QSPI READ : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 175, (uint8_t*)"QSPI Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)"QSPI READ : OK. ", LEFT_MODE); /*##-5- Checking data integrity ############################################*/ if(Buffercmp(qspi_aRxBuffer, qspi_aTxBuffer, BUFFER_SIZE) > 0) { BSP_LCD_DisplayStringAt(20, 175, (uint8_t*)"QSPI COMPARE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 190, (uint8_t*)"QSPI Test Aborted.", LEFT_MODE);//.........这里部分代码省略.........
开发者ID:z80,项目名称:stm32f429,代码行数:101,
示例22: NOR_demo/** * @brief NOR Demo * @param None * @retval None */void NOR_demo(void){ /* NOR IDs structure */ static NOR_IDTypeDef pNOR_ID; NOR_SetHint(); /* STM32F427x/437x/429x/439x "Revision 3" devices: FMC dynamic and static bank switching is allowed */ if (HAL_GetREVID() >= 0x2000) {} else { /* Disable the LCD to avoid the refrech from the SDRAM */ BSP_LCD_DisplayOff(); } /*##-1- Configure the NOR device ###########################################*/ /* NOR device configuration */ if(BSP_NOR_Init() != NOR_STATUS_OK) { ubInitStatus++; } /*##-2- Read & check the NOR device IDs ####################################*/ /* Initialize the ID structure */ pNOR_ID.Manufacturer_Code = (uint16_t)0x00; pNOR_ID.Device_Code1 = (uint16_t)0x00; pNOR_ID.Device_Code2 = (uint16_t)0x00; pNOR_ID.Device_Code3 = (uint16_t)0x00; /* Read the NOR memory ID */ BSP_NOR_Read_ID(&pNOR_ID); /* Test the NOR ID correctness */ if(pNOR_ID.Manufacturer_Code != (uint16_t)0x0020) ubIDStatus++; else if(pNOR_ID.Device_Code1 != (uint16_t)0x227E) ubIDStatus++; else if (pNOR_ID.Device_Code2 != (uint16_t)0x2221) ubIDStatus++; else if (pNOR_ID.Device_Code3 != (uint16_t)0x2200) ubIDStatus++; /*##-3- Erase NOR memory ###################################################*/ /* Return to read mode */ BSP_NOR_ReturnToReadMode(); if(BSP_NOR_Erase_Block(WRITE_READ_ADDR) != NOR_STATUS_OK) { ubEraseStatus++; } /*##-4- NOR memory read/write access ######################################*/ /* Fill the buffer to write */ Fill_Buffer(nor_aTxBuffer, BUFFER_SIZE, 0xC20F); /* Write data to the NOR memory */ if(BSP_NOR_WriteData(WRITE_READ_ADDR, nor_aTxBuffer, BUFFER_SIZE) != NOR_STATUS_OK) { ubWriteStatus++; } /* Read back data from the NOR memory */ if(BSP_NOR_ReadData(WRITE_READ_ADDR, nor_aRxBuffer, BUFFER_SIZE) != NOR_STATUS_OK) { ubReadStatus++; } /*##-5- Checking data integrity ############################################*/ /* STM32F427x/437x/429x/439x "Revision 3" devices: FMC dynamic and static bank switching is allowed */ if (HAL_GetREVID() >= 0x2000) {} else { /* Enable the LCD */ BSP_LCD_DisplayOn(); /* SDRAM initialization */ BSP_SDRAM_Init(); } if(ubIDStatus != 0) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"NOR Read ID : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"NOR Test Aborted.", LEFT_MODE); } else { if(ubInitStatus != 0) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"NOR Initialization : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"NOR Test Aborted.", LEFT_MODE); } else {//.........这里部分代码省略.........
开发者ID:eemei,项目名称:library-stm32f4,代码行数:101,
示例23: main/** * @brief Main program * @param None * @retval None */int main(void){ /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - 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 180 MHz */ SystemClock_Config(); /* Configure LED1, LED2, LED3 and LED4 */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* WAKEUP button (EXTI_Line0) will be used to wakeup the system from STOP mode */ BSP_PB_Init(BUTTON_WAKEUP, BUTTON_MODE_EXTI); /* Configure Key Button */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO); /*##-1- Configure the SDRAM device #########################################*/ /* SDRAM device configuration */ BSP_SDRAM_Init(); /*##-2- SDRAM memory write access ##########################################*/ /* Fill the buffer to write */ Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F); /* Write data to the SDRAM memory */ BSP_SDRAM_WriteData(SDRAM_DEVICE_ADDR + WRITE_READ_ADDR, aTxBuffer, BUFFER_SIZE); /* Wait for TAMPER/KEY to be pushed to enter stop mode */ while(BSP_PB_GetState(BUTTON_TAMPER) != RESET) { } /*##-3- Issue self-refresh command to SDRAM device #########################*/ SDRAMCommandStructure.CommandMode = FMC_SDRAM_CMD_SELFREFRESH_MODE; SDRAMCommandStructure.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; SDRAMCommandStructure.AutoRefreshNumber = 1; SDRAMCommandStructure.ModeRegisterDefinition = 0; if(BSP_SDRAM_Sendcmd(&SDRAMCommandStructure) != HAL_OK) { /* Command send Error */ Error_Handler(); } /*##-4- Enter CPU power stop mode ##########################################*/ /* Put LED4 on to indicate entering to STOP mode */ BSP_LED_On(LED4); /* Request to enter STOP mode */ HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI); /*##-5- Wakeup CPU from power stop mode ###################################*/ /* Configure the system clock after wakeup from STOP: enable HSE, PLL and select PLL as system clock source (HSE and PLL are disabled in STOP mode) */ SystemClock_Config(); /*##-6- SDRAM memory read back access ######################################*/ SDRAMCommandStructure.CommandMode = FMC_SDRAM_CMD_NORMAL_MODE; if(BSP_SDRAM_Sendcmd(&SDRAMCommandStructure) != HAL_OK) { /* Command send Error */ Error_Handler(); } /* Read back data from the SDRAM memory */ BSP_SDRAM_ReadData(SDRAM_DEVICE_ADDR + WRITE_READ_ADDR, aRxBuffer, BUFFER_SIZE); /*##-7- Checking data integrity ############################################*/ uwWriteReadStatus = Buffercmp(aTxBuffer, aRxBuffer, BUFFER_SIZE); if (uwWriteReadStatus != PASSED) { /* KO */ /* Turn on LED2 */ BSP_LED_On(LED2); } else { /* OK */ /* Turn on LED1 */ BSP_LED_On(LED1); } /* Infinite loop */ while (1)//.........这里部分代码省略.........
开发者ID:eemei,项目名称:library-stm32f4,代码行数:101,
示例24: main//.........这里部分代码省略......... } LCD_DisplayStringLine(LCD_LINE_2, " Send : Done "); STM_EVAL_LEDOn(LED2); STM_EVAL_LEDOn(LED3); STM_EVAL_LEDOn(LED4);#endif /* I2C_MASTER */ /**********************************Slave Code**********************************/#if defined (I2C_SLAVE) I2C_DeInit(I2Cx); /* Initialize I2C peripheral */ /*!< I2C Init */ I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_DutyCycle = I2C_DUTYCYCLE; I2C_InitStructure.I2C_OwnAddress1 = SLAVE_ADDRESS; I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; I2C_InitStructure.I2C_ClockSpeed = I2C_SPEED; #ifndef I2C_10BITS_ADDRESS I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;#else I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_10bit;#endif /* I2C_10BITS_ADDRESS */ I2C_Init(I2Cx, &I2C_InitStructure); /* Enable Error Interrupt */ I2C_ITConfig(I2Cx, (I2C_IT_ERR | I2C_IT_EVT | I2C_IT_BUF), ENABLE); /* I2C ENABLE */ I2C_Cmd(I2Cx, ENABLE); /* Slave Receiver-------------------------------------------------------------*/ Rx_Idx = 0x00; Tx_Idx = 0x00; /* Clear the RxBuffer */ Fill_Buffer(RxBuffer, RXBUFFERSIZE); /* Wait until end of data transfer */ while (Rx_Idx < RXBUFFERSIZE) {} TimeOut = USER_TIMEOUT; while ((I2C_GetFlagStatus(I2Cx, I2C_FLAG_BUSY))&&(TimeOut != 0x00)) {} if(TimeOut == 0) { TimeOut_UserCallback(); } if (Buffercmp(ExpectedCipherText, RxBuffer, RXBUFFERSIZE) == PASSED) { /* Clear the LCD */ LCD_Clear(LCD_COLOR_WHITE); /* Set the Back Color */ LCD_SetBackColor(LCD_COLOR_BLUE); /* Set the Text Color */ LCD_SetTextColor(LCD_COLOR_GREEN); LCD_DisplayStringLine(LCD_LINE_1, " Received : Done "); STM_EVAL_LEDOn(LED2); STM_EVAL_LEDOn(LED3); STM_EVAL_LEDOn(LED4); } else { /* Clear the LCD */ LCD_Clear(LCD_COLOR_WHITE); /* Set the Back Color */ LCD_SetBackColor(LCD_COLOR_BLUE); /* Set the Text Color */ LCD_SetTextColor(LCD_COLOR_GREEN); LCD_DisplayStringLine(LCD_LINE_1, " Receive : Failed "); STM_EVAL_LEDOff(LED2); STM_EVAL_LEDOff(LED3); STM_EVAL_LEDOff(LED4); }/* AES Decription ------------------------------------------------------------*/ AES_ECB_Decrypt(EncryptionKey, RxBuffer, AES_TEXT_SIZE, ComputedPlainText);/* Read the ComputedPlainText and check content correctness */ if (Buffercmp(TxBuffer, ComputedPlainText, RXBUFFERSIZE) == PASSED) { /* LED2, LED3 and LED4 Toggle */ LCD_DisplayStringLine(LCD_LINE_2, "Decryption : Success"); } else { /* ED2, LED3 and LED4 On */ LCD_DisplayStringLine(LCD_LINE_2, " Decryption : Failed"); }/* -------------------------------------------------------------------------- */#endif /* I2C_SLAVE */ while(1) {}}
开发者ID:RTOS-Developers,项目名称:TRTOS,代码行数:101,
示例25: SRAM_demo/** * @brief SRAM Demo * @param None * @retval None */void SRAM_demo (void){ SRAM_SetHint(); /* Disable the LCD to avoid the refrech from the SDRAM */ BSP_LCD_DisplayOff(); /*##-1- Configure the SRAM device ##########################################*/ /* SRAM device configuration */ if(BSP_SRAM_Init() != SRAM_OK) { ubSramInit++; } /*##-2- SRAM memory read/write access ######################################*/ /* Fill the buffer to write */ Fill_Buffer(sram_aTxBuffer, BUFFER_SIZE, 0xC20F); /* Write data to the SRAM memory */ if(BSP_SRAM_WriteData(SRAM_DEVICE_ADDR + WRITE_READ_ADDR, sram_aTxBuffer, BUFFER_SIZE) != SRAM_OK) { ubSramWrite++; } /* Read back data from the SRAM memory */ if(BSP_SRAM_ReadData(SRAM_DEVICE_ADDR + WRITE_READ_ADDR, sram_aRxBuffer, BUFFER_SIZE) != SRAM_OK) { ubSramRead++; } /*##-3- Checking data integrity ############################################*/ /* Enable the LCD */ BSP_LCD_DisplayOn(); if(ubSramInit != 0) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SRAM Initialization : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SRAM Initialization : OK.", LEFT_MODE); } if(ubSramWrite != 0) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SRAM WRITE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SRAM WRITE : OK.", LEFT_MODE); } if(ubSramRead != 0) { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SRAM READ : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SRAM READ : OK.", LEFT_MODE); } if(Buffercmp(sram_aRxBuffer, sram_aTxBuffer, BUFFER_SIZE) > 0) { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SRAM COMPARE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SRAM Test : OK.", LEFT_MODE); } while (1) { if(CheckForUserInput() > 0) { return; } }}
开发者ID:RadMie,项目名称:STM32F7DiscoveryBase,代码行数:85,
示例26: main/** * @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_stm32f0xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f0xx.c file */ /* SPI configuration ------------------------------------------------------*/ SPI_Config(); /* SysTick configuration ---------------------------------------------------*/ SysTickConfig(); /* Initialize LEDs mounted on STM320518-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); /* Master board configuration ------------------------------------------------*/#ifdef SPI_MASTER /* Initialize push-buttons mounted on STM320518-EVAL board */ STM_EVAL_PBInit(BUTTON_RIGHT, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_LEFT, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_UP, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_SEL, BUTTON_MODE_GPIO); /* Initializes the SPI communication */ SPI_InitStructure.SPI_Mode = SPI_Mode_Master; SPI_Init(SPIx, &SPI_InitStructure); /* Initialize the FIFO threshold */ SPI_RxFIFOThresholdConfig(SPIx, SPI_RxFIFOThreshold_QF); /* TIM configuration ------------------------------------------------------*/ TIM_Config(); /* Enable the SPI peripheral */ SPI_Cmd(SPIx, ENABLE); /* Enable NSS output for master mode */ SPI_SSOutputCmd(SPIx, ENABLE); /* TIM Capture Compare DMA Request enable */ TIM_DMACmd(TIMx, TIMx_DMA_CHANNEL, ENABLE); while (1) { /* DMA channel Rx of SPI Configuration */ DMA_InitStructure.DMA_BufferSize = (uint16_t)1; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)SPIx_DR_ADDRESS; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t) &CommandReceived; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_Init(SPIx_RX_DMA_CHANNEL, &DMA_InitStructure); /* DMA TIM trigger channel Configuration */ DMA_InitStructure.DMA_BufferSize = (uint16_t)1; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)SPIx_DR_ADDRESS; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t) &CommandTransmitted; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST; DMA_InitStructure.DMA_Priority = DMA_Priority_Low; DMA_Init(TIMx_CHANNEL_DMA_CHANNEL, &DMA_InitStructure); /* Enable the SPI Rx DMA request */ SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Rx, ENABLE); CommandTransmitted = 0x00; CommandReceived = 0x00; /* Clear the RxBuffer */ Fill_Buffer(RxBuffer, TXBUFFERSIZE); PressedButton = Read_Joystick(); while (PressedButton == JOY_NONE) { PressedButton = Read_Joystick(); } switch (PressedButton) { /* JOY_RIGHT button pressed */ case JOY_RIGHT: CommandTransmitted = CMD_RIGHT; NumberOfByte = CMD_RIGHT_SIZE; break; /* JOY_LEFT button pressed */ case JOY_LEFT: CommandTransmitted = CMD_LEFT; NumberOfByte = CMD_LEFT_SIZE; break; /* JOY_UP button pressed *///.........这里部分代码省略.........
开发者ID:ggajoch,项目名称:stm32-sudoku,代码行数:101,
示例27: 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,
示例28: main/** * @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_stm32f2xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f2xx.c file */ /* I2C configuration ---------------------------------------------------------*/ I2C_Config(); /* Initialize LEDs mounted on STM322xG-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); /* SysTick configuration -----------------------------------------------------*/ SysTickConfig(); /* Clear the RxBuffer */ Fill_Buffer(RxBuffer, RXBUFFERSIZE); /*************************************Master Code******************************/#if defined (I2C_MASTER) /* I2C Struct Initialize */ I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_DutyCycle = I2C_DUTYCYCLE; I2C_InitStructure.I2C_OwnAddress1 = 0xA0; I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; I2C_InitStructure.I2C_ClockSpeed = I2C_SPEED; #ifndef I2C_10BITS_ADDRESS I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;#else I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_10bit;#endif /* I2C_10BITS_ADDRESS */ /* I2C Initialize */ I2C_Init(I2Cx, &I2C_InitStructure); /* Master Transmitter --------------------------------------------------------*/ /* Generate the Start condition */ I2C_GenerateSTART(I2Cx, ENABLE); #ifdef I2C_10BITS_ADDRESS /* Test on I2C1 EV5 and clear it */ TimeOut = USER_TIMEOUT; while ((!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_MODE_SELECT))&&(TimeOut != 0x00)) {} if(TimeOut == 0) { TimeOut_UserCallback(); } /* Send Header to I2Cx for write or time out */ I2C_SendData(I2Cx, HEADER_ADDRESS_Write); /* Test on I2Cx EV9 and clear it */ TimeOut = USER_TIMEOUT; while ((!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_MODE_ADDRESS10))&&(TimeOut != 0x00)) {} if(TimeOut == 0) { TimeOut_UserCallback(); } /* Send I2Cx slave Address for write */ I2C_Send7bitAddress(I2Cx, (uint8_t)SLAVE_ADDRESS, I2C_Direction_Transmitter); #else /* I2C_7BITS_ADDRESS */ /* Test on I2Cx EV5 and clear it or time out */ TimeOut = USER_TIMEOUT; while ((!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_MODE_SELECT))&&(TimeOut != 0x00)) {} if(TimeOut == 0) { TimeOut_UserCallback(); } /* Send I2Cx slave Address for write */ I2C_Send7bitAddress(I2Cx, SLAVE_ADDRESS, I2C_Direction_Transmitter); #endif /* I2C_10BITS_ADDRESS */ /* Test on I2Cx EV6 and clear it or time out */ TimeOut = USER_TIMEOUT; while ((!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))&&(TimeOut != 0x00)) {} if(TimeOut == 0) { TimeOut_UserCallback(); } /* I2Cx DMA Enable */ I2C_DMACmd(I2Cx, ENABLE);//.........这里部分代码省略.........
开发者ID:JanusRC,项目名称:T2-Terminus,代码行数:101,
示例29: main/** * @brief Main program * @param None * @retval None */int main(void){ /* STM32F2xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - 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 120 MHz */ SystemClock_Config(); /* Configure LED1, LED2 and LED3 */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); /*##-1- Configure the SRAM device ##########################################*/ /* SRAM device configuration */ hsram.Instance = FSMC_NORSRAM_DEVICE; hsram.Extended = FSMC_NORSRAM_EXTENDED_DEVICE; SRAM_Timing.AddressSetupTime = 2; SRAM_Timing.AddressHoldTime = 1; SRAM_Timing.DataSetupTime = 2; SRAM_Timing.BusTurnAroundDuration = 1; SRAM_Timing.CLKDivision = 2; SRAM_Timing.DataLatency = 2; SRAM_Timing.AccessMode = FSMC_ACCESS_MODE_A; hsram.Init.NSBank = FSMC_NORSRAM_BANK2; hsram.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE; hsram.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM; hsram.Init.MemoryDataWidth = SRAM_MEMORY_WIDTH; hsram.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE; hsram.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW; hsram.Init.WrapMode = FSMC_WRAP_MODE_DISABLE; hsram.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS; hsram.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE; hsram.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE; hsram.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE; hsram.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE; hsram.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE; /* Initialize the SRAM controller */ if(HAL_SRAM_Init(&hsram, &SRAM_Timing, &SRAM_Timing) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /*##-2- SRAM memory read/write access ######################################*/ /* Fill the buffer to write */ Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xC20F); /* Write data to the SRAM memory */ for(uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++) { *(__IO uint16_t *)(SRAM_BANK_ADDR + WRITE_READ_ADDR + 2 * uwIndex) = aTxBuffer[uwIndex]; } /* Read back data from the SRAM memory */ for(uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++) { aRxBuffer[uwIndex] = *(__IO uint16_t *)(SRAM_BANK_ADDR + WRITE_READ_ADDR + 2 * uwIndex); } /*##-3- Checking data integrity ############################################*/ uwWriteReadStatus = Buffercmp(aTxBuffer, aRxBuffer, BUFFER_SIZE); if(uwWriteReadStatus != PASSED) { /* KO */ /* Turn on LED2 */ BSP_LED_On(LED2); } else { /* OK */ /* Turn on LED1 */ BSP_LED_On(LED1); } /* Infinite loop */ while (1) { }}
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:95,
示例30: main/** * @brief Main program * @param None * @retval None */int main(void){ /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - 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 180 MHz */ SystemClock_Config(); /* Configure LED1, LED2 and LED3 */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); /*##-1- Configure the SDRAM device #########################################*/ /* SDRAM device configuration */ hsdram.Instance = FMC_SDRAM_DEVICE; SDRAM_Timing.LoadToActiveDelay = 2; SDRAM_Timing.ExitSelfRefreshDelay = 6; SDRAM_Timing.SelfRefreshTime = 4; SDRAM_Timing.RowCycleDelay = 6; SDRAM_Timing.WriteRecoveryTime = 2; SDRAM_Timing.RPDelay = 2; SDRAM_Timing.RCDDelay = 2; hsdram.Init.SDBank = FMC_SDRAM_BANK1; hsdram.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; hsdram.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; hsdram.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH; hsdram.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; hsdram.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; hsdram.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; hsdram.Init.SDClockPeriod = SDCLOCK_PERIOD; hsdram.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; hsdram.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; /* Initialize the SDRAM controller */ if(HAL_SDRAM_Init(&hsdram, &SDRAM_Timing) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /* Program the SDRAM external device */ BSP_SDRAM_Initialization_Sequence(&hsdram, &command); /*##-2- SDRAM memory read/write access #####################################*/ /* Fill the buffer to write */ Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F); /* Write data to the SDRAM memory */ for (uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++) { *(__IO uint32_t*) (SDRAM_BANK_ADDR + WRITE_READ_ADDR + 4*uwIndex) = aTxBuffer[uwIndex]; } /* Read back data from the SDRAM memory */ for (uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++) { aRxBuffer[uwIndex] = *(__IO uint32_t*) (SDRAM_BANK_ADDR + WRITE_READ_ADDR + 4*uwIndex); } /*##-3- Checking data integrity ############################################*/ for (uwIndex = 0; (uwIndex < BUFFER_SIZE) && (uwWriteReadStatus == 0); uwIndex++) { if (aRxBuffer[uwIndex] != aTxBuffer[uwIndex]) { uwWriteReadStatus++; } } if (uwWriteReadStatus) { /* KO */ /* Turn on LED2 */ BSP_LED_On(LED2); } else { /* OK */ /* Turn on LED1 */ BSP_LED_On(LED1); } /* Infinite loop */ while (1) { }//.........这里部分代码省略.........
开发者ID:eemei,项目名称:library-stm32f4,代码行数:101,
注:本文中的Fill_Buffer函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ Filter函数代码示例 C++ FillRect函数代码示例 |