您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BSP_PB_Init函数代码示例

51自学网 2021-06-01 19:53:25
  C++
这篇教程C++ BSP_PB_Init函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中BSP_PB_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ BSP_PB_Init函数的具体用法?C++ BSP_PB_Init怎么用?C++ BSP_PB_Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了BSP_PB_Init函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){  /* STM32F0xx HAL library initialization:       - Configure the Flash prefetch       - 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.       - Low Level Initialization     */  HAL_Init();  /* Configure LEDs */  BSP_LED_Init(LED3);   BSP_LED_Init(LED4);  BSP_LED_Init(LED5);  /* Configure the system clock to 48 MHz */  SystemClock_Config();  /* Enable Power Clock */  __PWR_CLK_ENABLE();  /* Check and handle if the system was resumed from StandBy mode */  if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)  {    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);    /* Configure User push-button */    BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO);    /* Turn on the GREEN LED */    BSP_LED_On(LED5);    uwStandByOutFlag = 1;    /* Wait that user release the User push-button */    while(BSP_PB_GetState(BUTTON_USER) == GPIO_PIN_RESET){}  }  /* Infinite loop */  while(1)  {    /* Configure User push-button as external interrupt generator */    BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);    UserButtonStatus = 0;        /* Wait until User push-button is pressed to enter the Low Power mode.       In the meantime, LED3 is blinks */    while (UserButtonStatus == 0)    {      /* Toggle LED3 */      BSP_LED_Toggle(LED3);       HAL_Delay(100);      /* If exiting from stand-by mode, */      /*   keep LED5 ON for about 5 sec. */      if (uwStandByOutFlag > 0)      {        uwStandByOutFlag++;        if (uwStandByOutFlag == 50)        {          BSP_LED_Off(LED5);          uwStandByOutFlag = 0;         }      }            /* If exiting from stop mode thru RTC alarm        interrupt, keep LED6 ON for about 5 sec. */            if (uwWakeUpIntFlag > 0)      {        uwWakeUpIntFlag++;        if (uwWakeUpIntFlag == 50)        {          BSP_LED_Off(LED6);          uwWakeUpIntFlag = 0;         }      }    }    /* Make sure LED3 is turned off to        reduce low power mode consumption */    BSP_LED_Off(LED3);#if defined (SLEEP_MODE)    /* Sleep Mode Entry        - System Running at PLL (48 MHz)        - Flash 2 wait state        - Instruction and Data caches ON        - Prefetch ON        - Code running from Internal FLASH        - All peripherals disabled.        - Wakeup using EXTI Line (User push-button PA.00)    *///.........这里部分代码省略.........
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:101,


示例2: main

/**  * @brief  Main program.  * @param  None  * @retval None  */int main(void){  /* STM32F0xx HAL library initialization:       - Configure the Flash prefetch       - 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.       - Low Level Initialization     */  HAL_Init();  /* Configure LED3, LED4 and LED5 */  BSP_LED_Init(LED3);  BSP_LED_Init(LED4);  BSP_LED_Init(LED5);  /* Configure the system clock to 48 MHz */  SystemClock_Config();  /*##-1- Configure the SPI peripheral #######################################*/  /* Set the SPI parameters */  SpiHandle.Instance               = SPIx;  SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;  SpiHandle.Init.Direction         = SPI_DIRECTION_2LINES;  SpiHandle.Init.CLKPhase          = SPI_PHASE_1EDGE;  SpiHandle.Init.CLKPolarity       = SPI_POLARITY_LOW;  SpiHandle.Init.CRCCalculation    = SPI_CRCCALCULATION_DISABLE;  SpiHandle.Init.CRCPolynomial     = 7;  SpiHandle.Init.DataSize          = SPI_DATASIZE_8BIT;  SpiHandle.Init.FirstBit          = SPI_FIRSTBIT_MSB;  SpiHandle.Init.NSS               = SPI_NSS_SOFT;  SpiHandle.Init.TIMode            = SPI_TIMODE_DISABLE;  SpiHandle.Init.NSSPMode          = SPI_NSS_PULSE_DISABLE;  SpiHandle.Init.CRCLength         = SPI_CRC_LENGTH_8BIT;#ifdef MASTER_BOARD  SpiHandle.Init.Mode = SPI_MODE_MASTER;#else  SpiHandle.Init.Mode = SPI_MODE_SLAVE;#endif /* MASTER_BOARD */  if(HAL_SPI_Init(&SpiHandle) != HAL_OK)  {    /* Initialization Error */    Error_Handler();  }  #ifdef MASTER_BOARD  /* Configure Tamper push button */  BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO);  /* Wait for Tamper Button press before starting the Communication */  while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_SET)  {    BSP_LED_Toggle(LED3);    HAL_Delay(40);  }  BSP_LED_Off(LED3);#endif /* MASTER_BOARD */  /*##-2- Start the Full Duplex Communication process ########################*/    /* While the SPI in TransmitReceive process, user can transmit data through      "aTxBuffer" buffer & receive data through "aRxBuffer" */  if(HAL_SPI_TransmitReceive_IT(&SpiHandle, (uint8_t*)aTxBuffer, (uint8_t *)aRxBuffer, BUFFERSIZE) != HAL_OK)  {    /* Transfer error in transmission process */    Error_Handler();  }  /*##-3- Wait for the end of the transfer ###################################*/    /*  Before starting a new communication transfer, you need to check the current         state of the peripheral; if it’s busy you need to wait for the end of current      transfer before starting a new one.      For simplicity reasons, this example is just waiting till the end of the       transfer, but application may perform other tasks while transfer operation      is ongoing. */    while (HAL_SPI_GetState(&SpiHandle) != HAL_SPI_STATE_READY)  {  }   /*##-4- Compare the sent and received buffers ##############################*/  if(Buffercmp((uint8_t*)aTxBuffer, (uint8_t*)aRxBuffer, BUFFERSIZE))  {    /* Processing Error */    Error_Handler();       }  /* Infinite loop */    while (1)  {  }}
开发者ID:NjordCZ,项目名称:stm32cubef0,代码行数:98,


示例3: main

/**  * @brief  Main program.  * @param  None  * @retval None  */int main(void){  /* 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 the system clock to 216 MHz */  SystemClock_Config();  /* Since MFX is used, LED init is done after clock config */  /* Configure LED1, LED2, LED3 and LED4 */  BSP_LED_Init(LED1);  BSP_LED_Init(LED2);  BSP_LED_Init(LED3);  BSP_LED_Init(LED4);    /* Configure Tamper push-button */  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);  /*##-1- Configure the CAN peripheral #######################################*/  CAN_Config();  /*##-2- Start the Reception process and enable reception interrupt #########*/  if (HAL_CAN_Receive_IT(&CanHandle, CAN_FIFO0) != HAL_OK)  {    /* Reception Error */    Error_Handler();  }  /* Infinite loop */  while (1)  {    while (BSP_PB_GetState(BUTTON_TAMPER) == KEY_PRESSED)    {      if (ubKeyNumber == 0x4)      {        ubKeyNumber = 0x00;      }      else      {        LED_Display(++ubKeyNumber);                /* Set the data to be transmitted */        CanHandle.pTxMsg->Data[0] = ubKeyNumber;        CanHandle.pTxMsg->Data[1] = 0xAD;                /*##-3- Start the Transmission process ###############################*/        if (HAL_CAN_Transmit(&CanHandle, 10) != HAL_OK)        {          /* Transmission Error */          Error_Handler();        }        HAL_Delay(10);                while (BSP_PB_GetState(BUTTON_TAMPER) != KEY_NOT_PRESSED)        {        }      }    }  }}
开发者ID:MrZANE42,项目名称:verisure1512,代码行数:78,


示例4: 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 LED3 and LED4 */    BSP_LED_Init(LED3);    BSP_LED_Init(LED4);    /* Configure the system clock to 180 MHz */    SystemClock_Config();    /* Configure USER Button(EXTI_Line0) used to wake-up the system from STOP mode */    BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);    /*##-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 USER Button to be pushed to enter stop mode */    while(BSP_PB_GetState(BUTTON_KEY) == RESET)    {    }    /*##-3- Issue self-refresh command to SDRAM device #########################*/    SDRAMCommandStructure.CommandMode            = FMC_SDRAM_CMD_SELFREFRESH_MODE;    SDRAMCommandStructure.CommandTarget          = FMC_SDRAM_CMD_TARGET_BANK2;    SDRAMCommandStructure.AutoRefreshNumber      = 1;    SDRAMCommandStructure.ModeRegisterDefinition = 0;    if(BSP_SDRAM_Sendcmd(&SDRAMCommandStructure) != HAL_OK)    {        /* Command send Error */        Error_Handler();    }    /*##-4- Enter CPU power stop mode ##########################################*/    /* Turn LED3 and LED4 on to indicate entering to STOP mode */    BSP_LED_On(LED3);    BSP_LED_On(LED4);    /* Request to enter STOP mode */    HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);    /*##-5- Wake-up CPU from  power stop mode ##################################*/    /* Configure the system clock after wake-up from STOP: enable HSE, PLL and select         PLL as system clock source (HSE and PLL are disabled in STOP mode) */    SystemClock_Config();    /*##-6- Exit CPU power stop mode ###########################################*/    /* Turn LED3 and LED4 Off to indicate entering NORMAL mode */    BSP_LED_Off(LED3);    BSP_LED_Off(LED4);    /*##-7- 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);    /*##-8- Checking data integrity ############################################*/    uwWriteReadStatus = Buffercmp(aTxBuffer, aRxBuffer, BUFFER_SIZE);    if (uwWriteReadStatus != PASSED)    {        /* KO */        /* Turn on LED4 */        BSP_LED_On(LED4);    }    else    {        /* OK */        /* Turn on LED3 */        BSP_LED_On(LED3);    }    /* Infinite loop *///.........这里部分代码省略.........
开发者ID:PaxInstruments,项目名称:STM32CubeF4,代码行数:101,


示例5: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){  /* STM32F0xx HAL library initialization:       - Configure the Flash prefetch       - 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.       - Low Level Initialization     */  HAL_Init();    /* Configure LED2 */  BSP_LED_Init(LED2);  /* Configure the system clock to 168 Mhz */  SystemClock_Config();  /*##-1- Configure the UART peripheral ######################################*/  /* Put the USART peripheral in the Asynchronous mode (UART Mode) */  /* UART configured as follows:      - Word Length = 8 Bits      - Stop Bit = One Stop bit      - Parity = None      - BaudRate = 9600 baud      - Hardware flow control disabled (RTS and CTS signals) */  UartHandle.Instance        = USARTx;  UartHandle.Init.BaudRate   = 9600;  UartHandle.Init.WordLength = UART_WORDLENGTH_8B;  UartHandle.Init.StopBits   = UART_STOPBITS_1;  UartHandle.Init.Parity     = UART_PARITY_NONE;  UartHandle.Init.HwFlowCtl  = UART_HWCONTROL_NONE;  UartHandle.Init.Mode       = UART_MODE_TX_RX;  UartHandle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;  if(HAL_UART_DeInit(&UartHandle) != HAL_OK)  {    Error_Handler();  }    if(HAL_UART_Init(&UartHandle) != HAL_OK)  {    Error_Handler();  }  #ifdef TRANSMITTER_BOARD    /* Configure User push-button in Interrupt mode */  BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);    /* Wait for User push-button press before starting the Communication.     In the meantime, LED2 is blinking */  while(UserButtonStatus == 0)  {      /* Toggle LED2*/      BSP_LED_Toggle(LED2);       HAL_Delay(100);  }    BSP_LED_Off(LED2);       /* The board sends the message and expects to receive it back */    /*##-2- Start the transmission process #####################################*/    /* While the UART in reception process, user can transmit data through      "aTxBuffer" buffer */  if(HAL_UART_Transmit_DMA(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE)!= HAL_OK)  {    Error_Handler();  }    /*##-3- Wait for the end of the transfer ###################################*/    while (UartReady != SET)  {  }    /* Reset transmission flag */  UartReady = RESET;    /*##-4- Put UART peripheral in reception process ###########################*/   if(HAL_UART_DeInit(&UartHandle) != HAL_OK)  {    Error_Handler();  }    if(HAL_UART_Init(&UartHandle) != HAL_OK)  {    Error_Handler();  }     if(HAL_UART_Receive_DMA(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)  {    Error_Handler();  }//.........这里部分代码省略.........
开发者ID:jmoyerman,项目名称:stm32f0_cube,代码行数:101,


示例6: AudioPlay_demo

/**  * @brief Test Audio Hardware.  *   The main objective of this test is to check the hardware connection of the   *   Audio peripheral.  * @param  None  * @retval None  */void AudioPlay_demo(void){    WAVE_FormatTypeDef *waveformat =  NULL;  uint8_t Volume_string[20] = {0};  AudioPlay_SetHint();  /* Configuration of the EXTI for the joystick SEL push button for pause/resume */  /* UP/DOWN push buttons for change the volume */  BSP_PB_Init(BUTTON_SEL, BUTTON_MODE_EXTI);  BSP_PB_Init(BUTTON_UP, BUTTON_MODE_EXTI);  BSP_PB_Init(BUTTON_DOWN, BUTTON_MODE_EXTI);    /* Retrieve Wave Sample rate*/  waveformat = (WAVE_FormatTypeDef*) AUDIO_FILE_ADDRESS;  AudioPlay_DisplayInfos(waveformat);  /* Initialize Audio Device */  if(BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_HEADPHONE, volume, waveformat->SampleRate) != 0)  {    BSP_LCD_SetTextColor(LCD_COLOR_RED);        BSP_LCD_DisplayStringAt(0, 130, (uint8_t*)"Initialization problem", CENTER_MODE);     BSP_LCD_DisplayStringAt(0, 145, (uint8_t*)"Audio Codec not detected", CENTER_MODE);     BSP_LCD_DisplayStringAt(0, 160, (uint8_t*)"Verify that jumper JP4 and JP5", CENTER_MODE);    BSP_LCD_DisplayStringAt(0, 175, (uint8_t*)"are well set to I2C2 position", CENTER_MODE);    Error_Handler();  }    /* Set the total number of data to be played */  AudioTotalSize = (AUDIO_FILE_SIZE / AUDIODATA_SIZE);    /* Set the current audio pointer position */  CurrentPos = (uint16_t *)(AUDIO_FILE_ADDRESS);  /* Start the audio player */  if(BSP_AUDIO_OUT_Play(CurrentPos,DMA_MAX((AudioTotalSize))) != 0)  {    Error_Handler();  }  /* Turn ON LED green: start of Audio file play */  BSP_LED_On(LED_GREEN);  /* Update the remaining number of data to be played */  AudioRemSize = AudioTotalSize - DMA_MAX(AudioTotalSize);    /* Update the current audio pointer position */  CurrentPos += DMA_MAX(AudioTotalSize);  BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"Playback on-going", LEFT_MODE);  sprintf((char *) Volume_string, " Volume : %d%% ", volume);  BSP_LCD_DisplayStringAt((uint16_t)(-20), BSP_LCD_GetYSize()-30, Volume_string, RIGHT_MODE);  /* Infinite loop */  while(!CheckForUserInput())  {     if (PauseResumeStatus == PAUSE_STATUS)    {      /* Turn ON LED orange: Audio play in pause */      BSP_LED_On(LED_ORANGE);            /* Pause playing */      if(BSP_AUDIO_OUT_Pause() != 0)      {        Error_Handler();      }      BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"Playback paused  ", LEFT_MODE);      PauseResumeStatus = IDLE_STATUS;    }    else if (PauseResumeStatus == RESUME_STATUS)    {      /* Turn OFF LED orange: Audio play running */      BSP_LED_Off(LED_ORANGE);            /* Resume playing */      if(BSP_AUDIO_OUT_Resume() != 0)      {        Error_Handler();      }      BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"Playback on-going", LEFT_MODE);      PauseResumeStatus = IDLE_STATUS;    }      if (VolumeChange != 0)    {      VolumeChange = 0;      if(BSP_AUDIO_OUT_SetVolume(volume) != 0)      {        Error_Handler();      }      sprintf((char *) Volume_string, " Volume : %d%% ", volume);      BSP_LCD_DisplayStringAt((uint16_t)(-20), BSP_LCD_GetYSize()-30, Volume_string, RIGHT_MODE);    }  }    /* Reset the EXTI configuration for Joystick SEL, UP and DOWN push buttons *///.........这里部分代码省略.........
开发者ID:eleciawhite,项目名称:STM32Cube,代码行数:101,


示例7: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){  /* STM32F0xx HAL library initialization:       - Configure the Flash prefetch       - 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.       - Low Level Initialization     */  HAL_Init();    /* Configure the system clock to 48 MHz */  SystemClock_Config();  /* Configure LED_GREEN */  BSP_LED_Init(LED_GREEN);    /*##-1- Configure the I2C peripheral ######################################*/  I2cHandle.Instance             = I2Cx;    I2cHandle.Init.Timing          = I2C_TIMING;  I2cHandle.Init.OwnAddress1     = I2C_ADDRESS;  I2cHandle.Init.AddressingMode  = I2C_ADDRESSINGMODE_10BIT;  I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;  I2cHandle.Init.OwnAddress2     = 0xFF;  I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;  I2cHandle.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLED;      if(HAL_I2C_Init(&I2cHandle) != HAL_OK)  {    /* Initialization Error */    Error_Handler();      }  /* Enable the Analog I2C Filter */  HAL_I2CEx_AnalogFilter_Config(&I2cHandle,I2C_ANALOGFILTER_ENABLED);#ifdef MASTER_BOARD    /* Configure User push-button Button*/  BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO);  /* Wait for User push-button Button press before starting the Communication */  while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_RESET)  {  }    /* Wait for User push-button Button release before starting the Communication */  while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_SET)  {  }    /* The board sends the message and expects to receive it back */    /*##-2- Start the transmission process #####################################*/    /* While the I2C in reception process, user can transmit data through      "aTxBuffer" buffer */  while(HAL_I2C_Master_Transmit_IT(&I2cHandle, (uint16_t)I2C_ADDRESS, (uint8_t*)aTxBuffer, TXBUFFERSIZE)!= HAL_OK)  {    /* Error_Handler() function is called when Timout error occurs.       When Acknowledge failure ocucurs (Slave don't acknowledge it's address)       Master restarts communication */    if (HAL_I2C_GetError(&I2cHandle) != HAL_I2C_ERROR_AF)    {      Error_Handler();    }  }    /*##-3- Wait for the end of the transfer ###################################*/    /*  Before starting a new communication transfer, you need to check the current         state of the peripheral; if it’s busy you need to wait for the end of current      transfer before starting a new one.      For simplicity reasons, this example is just waiting till the end of the       transfer, but application may perform other tasks while transfer operation      is ongoing. */    while (HAL_I2C_GetState(&I2cHandle) != HAL_I2C_STATE_READY)  {  }     /* Wait for User push-button Button press before starting the Communication */  while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_RESET)  {  }    /* Wait for User push-button Button release before starting the Communication */  while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_SET)  {  }  /*##-4- Put I2C peripheral in reception process ###########################*/    while(HAL_I2C_Master_Receive_IT(&I2cHandle, (uint16_t)I2C_ADDRESS, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)  {    /* Error_Handler() function is called when Timout error occurs.//.........这里部分代码省略.........
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:101,


示例8: main

/** * @brief  Main program * @param  None * @retval None */int main(void){  uint8_t  lcd_status = LCD_OK;  /* This sample code displays a fixed image 800x480 on LCD KoD in */  /* orientation mode landscape and DSI mode video burst           */  /* 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();  /* Initialize used LED1 and LED3 */  BSP_LED_Init(LED1);  BSP_LED_Init(LED3);    /* Configure user push-button */  BSP_PB_Init(BUTTON_WAKEUP, BUTTON_MODE_GPIO);    /* Initialize the LCD DSI in Video Burst mode with LANDSCAPE orientation */  lcd_status = BSP_LCD_Init();  OnError_Handler(lcd_status != LCD_OK);    /* Program a line event at line 0 */  HAL_LTDC_ProgramLineEvent(&hltdc_eval, 0);      /* Copy texture to be displayed on LCD from Flash to SDRAM */  CopyPicture((uint32_t *)&candies_800x480_argb8888, (uint32_t *)LCD_FB_START_ADDRESS, 0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize());    BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER_BACKGROUND, LCD_FB_START_ADDRESS);  BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER_BACKGROUND);    /* Prepare area to display frame number in the image displayed on LCD */  BSP_LCD_SetTextColor(LCD_COLOR_BLUE);  BSP_LCD_FillRect(0, 400, BSP_LCD_GetXSize(), 80);  BSP_LCD_SetTextColor(LCD_COLOR_WHITE);  BSP_LCD_SetBackColor(LCD_COLOR_BLUE);  BSP_LCD_SetFont(&Font16);    /* Display title */  BSP_LCD_DisplayStringAt(0, 420, (uint8_t *) "LCD_DSI_ULPM_Data example", CENTER_MODE);  BSP_LCD_DisplayStringAt(0, 440, (uint8_t *) "Press TAMPER button to enter ULPM", CENTER_MODE);    BSP_LCD_SetTextColor(LCD_COLOR_WHITE);  BSP_LCD_SetBackColor(LCD_COLOR_BLUE);  BSP_LCD_SetFont(&Font16);    /* Infinite loop */  while (1)  {    /* Clear previous line */    BSP_LCD_ClearStringLine(460);        /* New text to display */    sprintf(str_display, ">> Frame Nb : %lu", frameCnt);        /* Print updated frame number */    BSP_LCD_DisplayStringAt(0, 460, (uint8_t *)str_display, CENTER_MODE);        if (CheckForUserInput() > 0)    {      /* Clear previous line */      BSP_LCD_SetTextColor(LCD_COLOR_GREEN);      BSP_LCD_ClearStringLine(440);      BSP_LCD_DisplayStringAt(0, 440, (uint8_t *) "Enter ULPM - switch Off LCD 6 seconds", CENTER_MODE);      BSP_LCD_SetTextColor(LCD_COLOR_WHITE);            /* Display Off with ULPM management Data lane only integrated */      BSP_LCD_DisplayOff();      HAL_Delay(1000);             /* Switch Off bit LTDCEN */      __HAL_LTDC_DISABLE(&hltdc_eval);             /* Enter ultra low power mode (data lane only integrated) */      HAL_DSI_EnterULPMData(&hdsi_eval);      BSP_LED_On(LED1);            HAL_Delay(6000);            BSP_LCD_ClearStringLine(440);      BSP_LCD_DisplayStringAt(0, 440, (uint8_t *) " Exited ULPM with success - Press To enter Again ULPM. ", CENTER_MODE);            /* Exit ultra low power mode (data lane only integrated) */      HAL_DSI_ExitULPMData(&hdsi_eval);//.........这里部分代码省略.........
开发者ID:z80,项目名称:stm32f429,代码行数:101,


示例9: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){  /* STM32F103xG HAL library initialization:       - Configure the Flash prefetch       - 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 the system clock to 72 MHz */  SystemClock_Config();    /* Configure LED1 and LED3 */  BSP_LED_Init(LED1);  BSP_LED_Init(LED3);    /*##-1- Configure the I2C peripheral ######################################*/  I2cHandle.Instance             = I2Cx;  I2cHandle.Init.ClockSpeed      = I2C_SPEEDCLOCK;  I2cHandle.Init.DutyCycle       = I2C_DUTYCYCLE;  I2cHandle.Init.OwnAddress1     = I2C_ADDRESS;  I2cHandle.Init.AddressingMode  = I2C_ADDRESSINGMODE_7BIT;  I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;  I2cHandle.Init.OwnAddress2     = 0xFF;  I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;  I2cHandle.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLE;      if(HAL_I2C_Init(&I2cHandle) != HAL_OK)  {    /* Initialization Error */    Error_Handler();  }  #ifdef MASTER_BOARD    /* Configure Key push-button */  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);  /* Wait for Key push-button press before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) != GPIO_PIN_RESET)  {  }    /* Wait for Key push-button release before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) != GPIO_PIN_SET)  {  }  while(1)  {    /* Initialize number of data variables */    hTxNumData = TXBUFFERSIZE;    hRxNumData = RXBUFFERSIZE;    /* Update bTransferRequest to send buffer write request for Slave */    bTransferRequest = MASTER_REQ_WRITE;    /*##-2- Master sends write request for slave #############################*/    while(HAL_I2C_Master_Transmit_IT(&I2cHandle, (uint16_t)I2C_ADDRESS, (uint8_t*)&bTransferRequest, 1)!= HAL_OK)    {      /* Error_Handler() function is called when Timeout error occurs.         When Acknowledge failure occurs (Slave don't acknowledge its address)         Master restarts communication */      if (HAL_I2C_GetError(&I2cHandle) != HAL_I2C_ERROR_AF)      {        Error_Handler();      }    }    /*  Before starting a new communication transfer, you need to check the current    state of the peripheral; if it’s busy you need to wait for the end of current    transfer before starting a new one.    For simplicity reasons, this example is just waiting till the end of the    transfer, but application may perform other tasks while transfer operation    is ongoing. */    while (HAL_I2C_GetState(&I2cHandle) != HAL_I2C_STATE_READY)    {    }    /*##-3- Master sends number of data to be written ########################*/    while(HAL_I2C_Master_Transmit_IT(&I2cHandle, (uint16_t)I2C_ADDRESS, (uint8_t*)&hTxNumData, 2)!= HAL_OK)    {      /* Error_Handler() function is called when Timeout error occurs.         When Acknowledge failure occurs (Slave don't acknowledge its address)         Master restarts communication */      if (HAL_I2C_GetError(&I2cHandle) != HAL_I2C_ERROR_AF)      {        Error_Handler();//.........这里部分代码省略.........
开发者ID:NjordCZ,项目名称:STM32Cube_FW_F1,代码行数:101,


示例10: 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 MHz */  SystemClock_Config();  /* -1- Initialize LEDs mounted on EVAL board */  /* Configure LED1*/  BSP_LED_Init(LED1);    /* -2- Configure User push-button in Gpio mode */  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);    /* Initialize the LCD */  BSP_LCD_Init();    /* Display message on EVAL LCD **********************************************/  /* Clear the LCD */   BSP_LCD_Clear(LCD_COLOR_BLUE);      /* Set the LCD Back Color */  BSP_LCD_SetBackColor(LCD_COLOR_BLUE);    /* Set the LCD Text Color */  BSP_LCD_SetTextColor(LCD_COLOR_WHITE);  BSP_LCD_DisplayStringAt(0, LINE(0), (uint8_t *)MESSAGE1, CENTER_MODE);  BSP_LCD_DisplayStringAt(0, LINE(1), (uint8_t *)MESSAGE2, CENTER_MODE);  BSP_LCD_DisplayStringAt(0, LINE(2), (uint8_t *)MESSAGE3, CENTER_MODE);    /* Turn on LEDs available on EVAL *******************************************/  BSP_LED_On(LED1);  BSP_LED_On(LED3);    BSP_LCD_SetFont(&Font16);  /* Initialize the Audio codec and all related peripherals (SAI, I2C, IOs...) */    if(BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_BOTH, uwVolume, SAI_AUDIO_FREQUENCY_48K) == 0)  {    BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"====================", CENTER_MODE);    BSP_LCD_SetFont(&Font12);    BSP_LCD_DisplayStringAt(0, LINE(8), (uint8_t *)"Short press on User button: Volume Down ", CENTER_MODE);    BSP_LCD_DisplayStringAt(0, LINE(9), (uint8_t *)"Long  press on User button: Pause/Resume", CENTER_MODE);    BSP_LCD_SetFont(&Font16);    BSP_LCD_DisplayStringAt(0, LINE(8), (uint8_t *)"====================", CENTER_MODE);    BSP_LCD_DisplayStringAt(0, LINE(9), (uint8_t *)"   AUDIO CODEC OK   ", CENTER_MODE);  }  else  {    BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"  AUDIO CODEC  FAIL ", CENTER_MODE);    BSP_LCD_DisplayStringAt(0, LINE(6), (uint8_t *)" Try to reset board ", CENTER_MODE);  }    /*   Start playing the file from a circular buffer, once the DMA is enabled, it is   always in running state. Application has to fill the buffer with the audio data   using Transfer complete and/or half transfer complete interrupts callbacks   (EVAL_AUDIO_TransferComplete_CallBack() or EVAL_AUDIO_HalfTransfer_CallBack()...  */  AUDIO_Start();    /* Display the state on the screen */  BSP_LCD_DisplayStringAt(0, LINE(10), (uint8_t *)"       PLAYING...     ", CENTER_MODE);     /* IMPORTANT:     AUDIO_Process() is called by the SysTick Handler, as it should be called      within a periodic process */     /* Infinite loop */  while(1)  {    if (BSP_PB_GetState(BUTTON_TAMPER) != RESET)    {       /* User push-button pressed, check if it is a long or a short press */      /* Insert 350 ms delay */      HAL_Delay(350);            if (BSP_PB_GetState(BUTTON_TAMPER) == RESET)      {        /* User push-button short press : Volume down *///.........这里部分代码省略.........
开发者ID:eemei,项目名称:library-stm32f4,代码行数:101,


示例11: 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 LED1, LED2, LED3 and LED4 */  BSP_LED_Init(LED1);  BSP_LED_Init(LED2);  BSP_LED_Init(LED3);  BSP_LED_Init(LED4);  /* Configure the system clock to 168 MHz */  SystemClock_Config();  /* Configure Key Button (EXTI_Line15) will be used to wakeup the system from STOP mode */  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);  /*## Configure the RTC peripheral #######################################*/  RTCHandle.Instance = RTC;    /* Configure RTC prescaler and RTC data registers as follow:  - Hour Format = Format 24  - Asynch Prediv = Value according to source clock  - Synch Prediv = Value according to source clock  - OutPut = Output Disable  - OutPutPolarity = High Polarity  - OutPutType = Open Drain */   RTCHandle.Init.HourFormat = RTC_HOURFORMAT_24;  RTCHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV;  RTCHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV;  RTCHandle.Init.OutPut = RTC_OUTPUT_DISABLE;  RTCHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;  RTCHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;  if(HAL_RTC_Init(&RTCHandle) != HAL_OK)  {    /* Initialization Error */    Error_Handler();   }  /* Infinite loop */    while (1)  {    /* Insert 5 second delay */    HAL_Delay(5000);  /*## Configure the Wake up timer ###########################################*/  /*  RTC Wakeup Interrupt Generation:      Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI))      Wakeup Time = Wakeup Time Base * WakeUpCounter                   = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) * WakeUpCounter      ==> WakeUpCounter = Wakeup Time / Wakeup Time Base      To configure the wake up timer to 4s the WakeUpCounter is set to 0x1FFF:        RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16         Wakeup Time Base = 16 /(~32.768KHz) = ~0,488 ms        Wakeup Time = ~4s = 0,488ms  * WakeUpCounter        ==> WakeUpCounter = ~4s/0,488ms = 8191 = 0x1FFF */    HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, 0x1FFF, RTC_WAKEUPCLOCK_RTCCLK_DIV16);    /* Turn OFF LED's */    BSP_LED_Off(LED1);    BSP_LED_Off(LED2);    BSP_LED_Off(LED3);    BSP_LED_Off(LED4);        /* Enter Stop Mode */    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);        /* Disable Wakeup Counter */    HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);        /* Configures system clock after wake-up from STOP: enable HSE, PLL and select     PLL as system clock source (HSE and PLL are disabled in STOP mode) */    SYSCLKConfig_STOP();  }}
开发者ID:451506709,项目名称:automated_machine,代码行数:85,


示例12: main

int_t main(void){    error_t error;    NetInterface *interface;    OsTask *task;    MacAddr macAddr;#if (APP_USE_DHCP == DISABLED)    Ipv4Addr ipv4Addr;#endif#if (APP_USE_SLAAC == DISABLED)    Ipv6Addr ipv6Addr;#endif    //MPU configuration    MPU_Config();    //HAL library initialization    HAL_Init();    //Configure the system clock    SystemClock_Config();    //Enable I-cache and D-cache    SCB_EnableICache();    SCB_EnableDCache();    //Initialize kernel    osInitKernel();    //Configure debug UART    debugInit(115200);    //Start-up message    TRACE_INFO("/r/n");    TRACE_INFO("**********************************/r/n");    TRACE_INFO("*** CycloneTCP FTP Client Demo ***/r/n");    TRACE_INFO("**********************************/r/n");    TRACE_INFO("Copyright: 2010-2015 Oryx Embedded SARL/r/n");    TRACE_INFO("Compiled: %s %s/r/n", __DATE__, __TIME__);    TRACE_INFO("Target: STM32F746/r/n");    TRACE_INFO("/r/n");    //LED configuration    BSP_LED_Init(LED1);    //Clear LEDs    BSP_LED_Off(LED1);    //Initialize user button    BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);    //Initialize LCD display    BSP_LCD_Init();    BSP_LCD_LayerDefaultInit(0, LCD_FRAME_BUFFER_LAYER0);    BSP_LCD_SelectLayer(0);    BSP_LCD_SetBackColor(LCD_COLOR_BLUE);    BSP_LCD_SetTextColor(LCD_COLOR_WHITE);    BSP_LCD_SetFont(&Font24);    BSP_LCD_DisplayOn();    //Clear LCD display    BSP_LCD_Clear(LCD_COLOR_BLUE);    //Welcome message    lcdSetCursor(0, 0);    printf("FTP Client Demo/r/n");    //TCP/IP stack initialization    error = netInit();    //Any error to report?    if(error)    {        //Debug message        TRACE_ERROR("Failed to initialize TCP/IP stack!/r/n");    }    //Configure the first Ethernet interface    interface = &netInterface[0];    //Set interface name    netSetInterfaceName(interface, "eth0");    //Set host name    netSetHostname(interface, "FTPClientDemo");    //Select the relevant network adapter    netSetDriver(interface, &stm32f7xxEthDriver);    netSetPhyDriver(interface, &lan8742PhyDriver);    //Set host MAC address    macStringToAddr(APP_MAC_ADDR, &macAddr);    netSetMacAddr(interface, &macAddr);    //Initialize network interface    error = netConfigInterface(interface);    //Any error to report?    if(error)    {        //Debug message        TRACE_ERROR("Failed to configure interface %s!/r/n", interface->name);    }#if (IPV4_SUPPORT == ENABLED)#if (APP_USE_DHCP == ENABLED)    //Get default settings    dhcpClientGetDefaultSettings(&dhcpClientSettings);    //Set the network interface to be configured by DHCP//.........这里部分代码省略.........
开发者ID:miragecentury,项目名称:M2_SE_RTOS_Project,代码行数:101,


示例13: 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, LED2, LED3 and LED4 */  BSP_LED_Init(LED1);  BSP_LED_Init(LED2);  BSP_LED_Init(LED3);  BSP_LED_Init(LED4);  /*##-1- Configure the UART peripheral ######################################*/  /* Put the USART peripheral in the Asynchronous mode (UART Mode) */  /* UART configured as follows:      - Word Length = 8 Bits      - Stop Bit = One Stop bit      - Parity = None      - BaudRate = 9600 baud      - Hardware flow control disabled (RTS and CTS signals) */  UartHandle.Instance        = USARTx;  UartHandle.Init.BaudRate     = 115200;  UartHandle.Init.WordLength   = UART_WORDLENGTH_8B;  UartHandle.Init.StopBits     = UART_STOPBITS_1;  UartHandle.Init.Parity       = UART_PARITY_NONE;  UartHandle.Init.HwFlowCtl    = UART_HWCONTROL_NONE;  UartHandle.Init.Mode         = UART_MODE_TX_RX;  UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;  if(HAL_UART_DeInit(&UartHandle) != HAL_OK)  {    Error_Handler();  }    if(HAL_UART_Init(&UartHandle) != HAL_OK)  {    Error_Handler();  }  #ifdef TRANSMITTER_BOARD  /* Configure User push-button in Interrupt mode */  BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);    /* Wait for User push-button press before starting the Communication.     In the meantime, LED2 is blinking */  while(UserButtonStatus == 0)  {      /* Toggle LED2*/      BSP_LED_Toggle(LED2);       HAL_Delay(100);  }    BSP_LED_Off(LED2);   /* The board sends the message and expects to receive it back */    /*##-2- Start the transmission process #####################################*/    /* While the UART in reception process, user can transmit data through      "aTxBuffer" buffer */  if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE, 5000)!= HAL_OK)  {    Error_Handler();     }    /* Turn LED4 on: Transfer in transmission process is correct */  BSP_LED_On(LED4);    /*##-3- Put UART peripheral in reception process ###########################*/    if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 5000) != HAL_OK)  {    Error_Handler();    }     /* Turn LED3 on: Transfer in reception process is correct */  BSP_LED_On(LED3); #else    /* The board receives the message and sends it back */  /*##-2- Put UART peripheral in reception process ###########################*/  if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 0x1FFFFFF) != HAL_OK)  {    Error_Handler();//.........这里部分代码省略.........
开发者ID:Lembed,项目名称:STM32CubeF4-mirrors,代码行数:101,


示例14: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){ /* This sample code shows how to use STM32F4xx CEC HAL API to transmit and   * receive data. The device is set in waiting to receive mode and sends  * messages when the evaluation board buttons are pushed by the user */    /* STM32F4xx HAL library initialization:       - Configure the Flash prefetch       - 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 the system clock to 180 MHz */  SystemClock_Config();  /* -1- Initialize LEDs mounted on EVAL board */  /* Configure LED1, LED2, LED3 and LED4 */  BSP_LED_Init(LED1);  BSP_LED_Init(LED2);  BSP_LED_Init(LED3);  BSP_LED_Init(LED4);  /* -2- Configure User push-button in Interrupt mode */  /* button-triggered interruptions initialization */  BSP_PB_Init(BUTTON_TAMPER,BUTTON_MODE_EXTI);    /* -3- Configure Joystick Selection push-button in Interrupt mode */  BSP_JOY_Init(JOY_MODE_EXTI);    /* CEC device initialization */  /* -4- CEC configuration (transfer will take place in Interrupt mode) */  #if defined (DEVICE_1)  /* Device 1:    * a single logical address ... */  MyLogicalAddress1 = DEVICE_ADDRESS_1;  /* ... and two different follower addresses */  MyFollowerAddress1 = DEVICE_ADDRESS_2;  MyFollowerAddress2 = DEVICE_ADDRESS_3;#elif defined (DEVICE_2)  /* Device 2:    * two different logical addresses ... */  MyLogicalAddress1 = DEVICE_ADDRESS_2;  MyLogicalAddress2 = DEVICE_ADDRESS_3;    /* ... and a single follower address */  MyFollowerAddress1 = DEVICE_ADDRESS_1;#endif /* DEVICE_1 */        /* -5- CEC configuration (transfer will take place in Interrupt mode) */  hcec.Instance = CEC;  /* Deinitialize CEC to reinitialize from scratch */  HAL_CEC_DeInit(&hcec);  /* IP configuration */   CEC_Config(&hcec);    /* -6- CEC transfer general variables initialization */  ReceivedFrame = 0;  StartSending = 0;  NbOfReceivedBytes = 0;  CEC_FlushRxBuffer();      /* Test start */      /* Enter infinite reception loop: the CEC device is set in   * waiting to receive mode.    * The CEC "background" state is HAL_CEC_STATE_STANDBY_RX.   * Upon any message reception or transmission, the CEC    * comes back to that state.   * It is up to the user to define exit conditions in modifying   * accordingly the RX, TX or Error callback functions. */  HAL_CEC_Receive_IT(&hcec, (uint8_t *)&Tab_Rx);   while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_READY)  {        /* if no reception has occurred and no error has been detected,     * transmit a message if the user has pushed a button */    if( (StartSending == 1) && (ReceivedFrame == 0))    {       HAL_CEC_Transmit_IT(&hcec, DestinationAddress, (uint8_t *)&Tab_Tx, TxSize);      /* loop until TX ends or TX error reported */        while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_STANDBY_RX);      StartSending = 0;    }          /* if a frame has been received */    if (ReceivedFrame == 1)//.........这里部分代码省略.........
开发者ID:nidhiyanandh,项目名称:STM32Cube_FW_F4_V1.5.0_GCC_Makefile,代码行数:101,


示例15: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){  /* STM32F3xx HAL library initialization:       - Configure the Flash prefetch       - 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 Green, Red and Orange LEDs */  BSP_LED_Init(LED_GREEN);  BSP_LED_Init(LED_RED);  BSP_LED_Init(LED_ORANGE);        /* Configure the system clock to 72 Mhz */  SystemClock_Config();   /* Enable Power Clock */  __PWR_CLK_ENABLE();    /* Check and handle if the system was resumed from StandBy mode */   if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)  {    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);    /* Turn on the Orange LED */    BSP_LED_On(LED_ORANGE);    uwStandByOutFlag = 1;  }  /* infinite loop */  while(1)  {    /* Configure User Button */    BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);    UserButtonStatus = 0;        /* Wait until User button is pressed to enter the Low Power mode.       In the meantime, LED_GREEN is blinking */    while(UserButtonStatus == 0)    {      BSP_LED_Toggle(LED_GREEN);       HAL_Delay(100);            /* if exiting from stand-by mode,          keep LED_ORANGE ON for about 3 sec. */      if (uwStandByOutFlag > 0)      {        uwStandByOutFlag++;        if (uwStandByOutFlag == 30)        {          BSP_LED_Off(LED_ORANGE);          uwStandByOutFlag = 0;         }      }      /* if exiting from stop mode thru RTC alarm        interrupt, keep LED_ORANGE ON for about 3 sec. */            if (uwWakeUpIntFlag > 0)      {        uwWakeUpIntFlag++;        if (uwWakeUpIntFlag == 30)        {          BSP_LED_Off(LED_BLUE);          uwWakeUpIntFlag = 0;         }      }    }        /* Loop while Key button is maintained pressed */    while(BSP_PB_GetState(BUTTON_USER) != SET) {}             /* Make sure LED_GREEN is turned off to       reduce low power mode consumption */    BSP_LED_Off(LED_GREEN);    #if defined (SLEEP_MODE)    /* Sleep Mode Entry     - System Running at PLL (72 MHz)    - Flash 2 wait state    - Instruction and Data caches ON    - Prefetch ON    - Code running from Internal FLASH    - All peripherals disabled.    - Wakeup using EXTI Line (User Button PA.00)    */    SleepMode_Measure();#elif defined (STOP_MODE)    /* STOP Mode Entry //.........这里部分代码省略.........
开发者ID:afconsult-south,项目名称:dragonfly-fcb,代码行数:101,


示例16: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){  /* STM32L0xx HAL library initialization:       - Configure the Flash prefetch, Flash preread and Buffer 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.       - Low Level Initialization     */  HAL_Init();  /* Configure the system clock to 2 MHz */  SystemClock_Config();#if defined(TERMINAL_IO_OUT)  /* Configure Key Button */  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);#else   /* Configure the COM port */  UartHandle.Init.BaudRate = 115200;  UartHandle.Init.WordLength = UART_WORDLENGTH_8B;  UartHandle.Init.StopBits = UART_STOPBITS_1;  UartHandle.Init.Parity = UART_PARITY_NONE;  UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;  UartHandle.Init.Mode = UART_MODE_TX_RX;  BSP_COM_Init(COM1, &UartHandle);#endif  /* Configures LED */  BSP_LED_Init(LED2);  /*##- Configure the CRYP peripheral ######################################*/  /* Set the common CRYP parameters */  CrypHandle.Instance = AES;  CrypHandle.Init.DataType = CRYP_DATATYPE_8B;  if (HAL_CRYP_Init(&CrypHandle) != HAL_OK)  {    /* Initialization Error */    Error_Handler();  }  /* Infinite loop */  while (1)  {  /* Display Plain Data*/  Display_PlainData(AES_TEXT_SIZE);      /* Display Cypher Data*/  Display_CypherData(AES_TEXT_SIZE);#if defined(TERMINAL_IO_OUT)  printf("/n/r Press User button to continue.../n/r ");  /* Wait until Key button is pressed to enter the next mode */  while(BSP_PB_GetState(BUTTON_KEY) != RESET){}  /* Loop while Key button is maintained pressed */  while(BSP_PB_GetState(BUTTON_KEY) == RESET){}#else     PressToContinue();#endif   BSP_LED_Off(LED2);    /******************************************************************************/    /*                             AES mode ECB                                   */    /******************************************************************************/    if (HAL_CRYP_DeInit(&CrypHandle) != HAL_OK)    {      Error_Handler();    }    /*=====================================================        Encryption ECB mode    ======================================================*/    /*****************  AES 128   ****************/    /* Initialize the CRYP peripheral */    CrypHandle.Instance = AES;    CrypHandle.Init.pKey          = aAES128key;    if (HAL_CRYP_Init(&CrypHandle) != HAL_OK)    {      /* Initialization Error */      Error_Handler();    }    /* Start encrypting aPlaintext, the cypher data is available in aEncryptedtext */    if (HAL_CRYP_AESECB_Encrypt(&CrypHandle, aPlaintext, AES_TEXT_SIZE, aEncryptedtext, TIMEOUT_VALUE) == HAL_OK)    {      /* Display encrypted Data *///.........这里部分代码省略.........
开发者ID:pengphei,项目名称:STM32Cube_L0,代码行数:101,


示例17: 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 LED3, LED4, LED5 & LED6 */    BSP_LED_Init(LED3);    BSP_LED_Init(LED4);    BSP_LED_Init(LED5);    BSP_LED_Init(LED6);    /* Configure the system clock to 168 Mhz */    SystemClock_Config();    /*##-1- Configure the UART peripheral ######################################*/    /* Put the USART peripheral in the Asynchronous mode (UART Mode) */    /* UART1 configured as follow:        - Word Length = 8 Bits        - Stop Bit = One Stop bit        - Parity = None        - BaudRate = 9600 baud        - Hardware flow control disabled (RTS and CTS signals) */    UartHandle.Instance        = USARTx;    UartHandle.Init.BaudRate   = 9600;    UartHandle.Init.WordLength = UART_WORDLENGTH_8B;    UartHandle.Init.StopBits   = UART_STOPBITS_1;    UartHandle.Init.Parity     = UART_PARITY_NONE;    UartHandle.Init.HwFlowCtl  = UART_HWCONTROL_NONE;    UartHandle.Init.Mode       = UART_MODE_TX_RX;    if(HAL_UART_Init(&UartHandle) != HAL_OK)    {        Error_Handler();    }#ifdef TRANSMITTER_BOARD    /* Configure Button Key */    BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);    /* Wait for Button Key press before starting the Communication */    while (BSP_PB_GetState(BUTTON_KEY) == RESET)    {        /* Toggle led3 waiting for user to press button */        BSP_LED_Toggle(LED3);        HAL_Delay(40);    }    /* Wait for Button Key to be release before starting the Communication */    while (BSP_PB_GetState(BUTTON_KEY) == SET)    {    }    /* Turn led3 off */    BSP_LED_Off(LED3);    /* The board sends the message and expects to receive it back */    /*##-2- Start the transmission process #####################################*/    /* While the UART in reception process, user can transmit data through       "aTxBuffer" buffer */    if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE, 5000)!= HAL_OK)    {        Error_Handler();    }    /* Turn LED6 on: Transfer in transmission process is correct */    BSP_LED_On(LED6);    /*##-3- Put UART peripheral in reception process ###########################*/    if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 5000) != HAL_OK)    {        Error_Handler();    }    /* Turn LED4 on: Transfer in reception process is correct */    BSP_LED_On(LED4);#else    /* The board receives the message and sends it back */    /*##-2- Put UART peripheral in reception process ###########################*/    if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 5000) != HAL_OK)    {        Error_Handler();    }    /* Turn LED4 on: Transfer in reception process is correct */    BSP_LED_On(LED4);//.........这里部分代码省略.........
开发者ID:Guidoted,项目名称:STM32Cube_FW_F4,代码行数:101,


示例18: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){	uint8_t lcd_status = LCD_OK;          p_bmp_converted_pixel_data    = (uint8_t *)CONVERTED_FRAME_BUFFER;  offset_address_area_cam_in_lcd_buffer = ((((LcdResY - CameraResY) / 2) * LcdResX)                                          +   ((LcdResX - CameraResX) / 2))                                          * ARGB8888_BYTE_PER_PIXEL;  /* For the first Camera line event callback : set the offset to display camera image in the center */  /* of LCD frame buffer background */  lcd_datapointer = offset_address_area_cam_in_lcd_buffer;	/* 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();  BSP_IO_Init();  /* Reset and power down camera to be sure camera is Off prior start testing BSP */  BSP_CAMERA_HwReset();  BSP_CAMERA_PwrDown();  /* Configure LED1 and LED3 */  BSP_LED_Init(LED1);  BSP_LED_Init(LED3);  /*##-1- LCD DSI initialization in mode Video Burst  with two LTDC layers of size 800x480 */  lcd_status = BSP_LCD_Init();  if(lcd_status != LCD_OK)  {	  Error_Handler();  }    BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER_BACKGROUND, LCD_BG_LAYER_ADDRESS);  BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER_FOREGROUND, LCD_FB_START_ADDRESS);  /* Select Foreground Layer */  BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER_FOREGROUND);  /* Clear the LCD Foreground layer */  BSP_LCD_Clear(LCD_COLOR_WHITE);  /* Disable the LTDC Foreground layer */  BSP_LCD_SetLayerVisible(LTDC_ACTIVE_LAYER_FOREGROUND, DISABLE);  /* Select the LCD Background layer */  BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER_BACKGROUND);  BSP_LCD_Clear(LCD_COLOR_WHITE);  /*##-2- Init Host Library ##################################################*/  /* Display USB initialization message */  BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);  BSP_LCD_SetFont(&Font24);  BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize() - 24), (uint8_t *)"USB init ..", RIGHT_MODE);  USBH_Init(&hUSB_Host, USBH_UserProcess, 0);  /* Add Supported Class */  USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);  /* Start Host Process */  USBH_Start(&hUSB_Host);  /*##-3- Configure TAMPER Button ############################################*/  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);  /*##-4- Link the USB Host disk I/O driver ##################################*/  FATFS_LinkDriver(&USBH_Driver, MSC_Path);  /*##-5- Camera Initialization and start capture ############################*/  /* Display camera initialization message */  BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize() - 24), (uint8_t *)"Camera init ..", RIGHT_MODE);  /* Initialize the Camera */  BSP_CAMERA_Init(RESOLUTION_R480x272);  /* Start the Camera Capture */  BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);  BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize() - 48), (uint8_t *)"Press TAMPER button to take snapshot", RIGHT_MODE);  BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize() - 24), (uint8_t *)"Camera Play ..", RIGHT_MODE);  /*##-6- Run Application ####################################################*/  while (1)//.........这里部分代码省略.........
开发者ID:Lembed,项目名称:STM32CubeF4-mirrors,代码行数:101,


示例19: SleepMode_Measure

/**  * @brief  This function configures the system to enter Sleep mode for  *         current consumption measurement purpose.  *         Sleep Mode  *         ==========  *            - System Running at PLL (168MHz)  *            - Flash 5 wait state  *            - Instruction and Data caches ON  *            - Prefetch ON  *            - Code running from Internal FLASH  *            - All peripherals disabled.  *            - Wakeup using EXTI Line (USER Button)  * @param  None  * @retval None  */void SleepMode_Measure(void){  GPIO_InitTypeDef GPIO_InitStruct;  /* Configure all GPIO as analog to reduce current consumption on non used IOs */  /* Enable GPIOs clock */   __HAL_RCC_GPIOA_CLK_ENABLE();   __HAL_RCC_GPIOB_CLK_ENABLE();   __HAL_RCC_GPIOC_CLK_ENABLE();   __HAL_RCC_GPIOD_CLK_ENABLE();   __HAL_RCC_GPIOE_CLK_ENABLE();   __HAL_RCC_GPIOF_CLK_ENABLE();   __HAL_RCC_GPIOG_CLK_ENABLE();   __HAL_RCC_GPIOH_CLK_ENABLE();   __HAL_RCC_GPIOI_CLK_ENABLE();  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;  GPIO_InitStruct.Pull = GPIO_NOPULL;  GPIO_InitStruct.Pin = GPIO_PIN_All;  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);  /* Disable GPIOs clock */   __HAL_RCC_GPIOA_CLK_DISABLE();   __HAL_RCC_GPIOB_CLK_DISABLE();   __HAL_RCC_GPIOC_CLK_DISABLE();   __HAL_RCC_GPIOD_CLK_DISABLE();   __HAL_RCC_GPIOE_CLK_DISABLE();   __HAL_RCC_GPIOF_CLK_DISABLE();   __HAL_RCC_GPIOG_CLK_DISABLE();   __HAL_RCC_GPIOH_CLK_DISABLE();   __HAL_RCC_GPIOI_CLK_DISABLE();  /* Configure USER Button */  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);  /* Suspend Tick increment to prevent wakeup by Systick interrupt.     Otherwise the Systick interrupt will wake up the device within 1ms (HAL time base) */  HAL_SuspendTick();  /* Request to enter SLEEP mode */  HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);  /* Resume Tick interrupt if disabled prior to sleep mode entry */  HAL_ResumeTick();  /* Configure LED3 */  BSP_LED_Init(LED3);  /* Turn LED3 On */  BSP_LED_On(LED3);  /* Add a delay of 2 second after exit from Sleep mode */  HAL_Delay(200);}
开发者ID:Joe-Merten,项目名称:Stm32-Tools-Evaluation,代码行数:78,


示例20: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){  /* Configure Key Button */        BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);      /* Test if Key push-button is not pressed */  if (BSP_PB_GetState(BUTTON_KEY) != 0x00)  { /* Key push-button not pressed: jump to user application */        /* Check if valid stack address (RAM address) then jump to user application */    if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000)    {      /* Jump to user application */      JumpAddress = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);      Jump_To_Application = (pFunction) JumpAddress;      /* Initialize user application's Stack Pointer */      __set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);      Jump_To_Application();      /* do nothing */      while(1);    }    else    {/* Otherwise, do nothing */      /* LED3 (RED) ON to indicate bad software (when not valid stack address) */      BSP_LED_Init(LED3);      BSP_LED_On(LED3);      /* do nothing */      while(1);    }  }  /* Enter in IAP mode */  else  {    /* 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 168 MHz */    SystemClock_Config();        /* Configure the BSP */    BSP_Config();        /* Initialize the LwIP stack */    lwip_init();        /* Configure the Network interface */    Netif_Config();    #ifdef USE_IAP_HTTP    /* Initialize the webserver module */    IAP_httpd_init();#endif    #ifdef USE_IAP_TFTP        /* Initialize the TFTP server */    IAP_tftpd_init();#endif          /* Notify user about the network interface config */    User_notification(&gnetif);        /* Infinite loop */    while (1)    {    /* Read a received packet from the Ethernet buffers and send it        to the lwIP for handling */    ethernetif_input(&gnetif);    /* Handle timeouts */    sys_check_timeouts();#ifdef USE_DHCP    /* handle periodic timers for LwIP */    DHCP_Periodic_Handle(&gnetif);#endif     }  }}
开发者ID:nidhiyanandh,项目名称:STM32Cube_FW_F4_V1.5.0_GCC_Makefile,代码行数:88,


示例21: main

/**  * @brief  Main program.  * @param  None  * @retval None  */int main(void){  /* STM32F103xG HAL library initialization:       - Configure the Flash prefetch       - 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 the system clock to 72 MHz */  SystemClock_Config();    /*## Configure peripherals #################################################*/    /* Initialize LEDs on board */  BSP_LED_Init(LED3);  BSP_LED_Init(LED1);    /* Configure Key push-button in Interrupt mode */  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);    /* Configure the ADC peripheral */  ADC_Config();    /* Run the ADC calibration */    if (HAL_ADCEx_Calibration_Start(&AdcHandle) != HAL_OK)  {    /* Calibration Error */    Error_Handler();  }#if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST)  /* Configure the DAC peripheral */  DAC_Config();#endif /* WAVEFORM_VOLTAGE_GENERATION_FOR_TEST */    /*## Enable peripherals ####################################################*/  #if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST)  /* Set DAC Channel data register: channel corresponding to ADC channel CHANNELa */  /* Set DAC output to 1/2 of full range (4095 <=> Vdda=3.3V): 2048 <=> 1.65V              */  if (HAL_DAC_SetValue(&DacHandle, DACx_CHANNEL_TO_ADCx_CHANNELa, DAC_ALIGN_12B_R, RANGE_12BITS/2) != HAL_OK)  {    /* Setting value Error */    Error_Handler();  }    /* Enable DAC Channel: channel corresponding to ADC channel CHANNELa */  if (HAL_DAC_Start(&DacHandle, DACx_CHANNEL_TO_ADCx_CHANNELa) != HAL_OK)  {    /* Start Error */    Error_Handler();  }#endif /* WAVEFORM_VOLTAGE_GENERATION_FOR_TEST */  /*## Start ADC conversions #################################################*/    /* Start ADC conversion on regular group with transfer by DMA */  if (HAL_ADC_Start_DMA(&AdcHandle,                        (uint32_t *)aADCxConvertedValues,                        ADCCONVERTEDVALUES_BUFFER_SIZE                       ) != HAL_OK)  {    /* Start Error */    Error_Handler();  }      /* Infinite loop */  while (1)  {    /* Wait for event on push button to perform following actions */    while ((ubUserButtonClickEvent) == RESET)    {    }    /* Reset variable for next loop iteration */    ubUserButtonClickEvent = RESET;#if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST)    /* Set DAC voltage on channel corresponding to ADCx_CHANNELa              */    /* in function of user button clicks count.                               */    /* Set DAC output successively to:                                        */    /*  - minimum of full range (0 <=> ground 0V)                             */    /*  - 1/4 of full range (4095 <=> Vdda=3.3V): 1023 <=> 0.825V             */    /*  - 1/2 of full range (4095 <=> Vdda=3.3V): 2048 <=> 1.65V              */    /*  - 3/4 of full range (4095 <=> Vdda=3.3V): 3071 <=> 2.475V             */    /*  - maximum of full range (4095 <=> Vdda=3.3V)                          *///.........这里部分代码省略.........
开发者ID:dazuo78,项目名称:TBall,代码行数:101,


示例22: 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 168 MHz */  SystemClock_Config();    /* Configure LED1 and LED3 */  BSP_LED_Init(LED1);  BSP_LED_Init(LED3);    /*##-1- 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);    /*##-2- Disable SAI1_SDA signal ############################################*/    /* Note: In STM324x9I-EVAL RevB, PE6 pin is shared between data_7 of camera            and SAI1_SDA of codec WM8994, after power on, SAI1_SDA pin of codec WM8994            is in output state, thus preventing MCU from receiving correct signal            from camera, so we need to configure SAI1_SDA pin of codec WM8994            in tri-state */    /* Initialize the Control interface of the Audio Codec */  BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_SPEAKER, 70, AUDIO_FREQUENCY_48K);   /* ADCDAT1 is tri-stated */  AUDIO_IO_Write(AUDIO_I2C_ADDRESS, 0x200, 0);  AUDIO_IO_Write(AUDIO_I2C_ADDRESS, 0x300, 0x6010);    /*##-3- Configure TAMPER Button ############################################*/  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);    /*##-4- Link the USB Host disk I/O driver ##################################*/  FATFS_LinkDriver(&USBH_Driver, MSC_Path);    /*##-5- Initialize the LCD #################################################*/  BSP_LCD_Init();    /* Foreground Layer Initialization */  BSP_LCD_LayerDefaultInit(1, LCD_FRAME_BUFFER_LAYER1);  /* Set Foreground Layer */  BSP_LCD_SelectLayer(1);  /* Clear the LCD Foreground layer */  BSP_LCD_Clear(LCD_COLOR_WHITE);  BSP_LCD_SetLayerVisible(1, DISABLE);    /* Background Layer Initialization */  BSP_LCD_LayerDefaultInit(0, LCD_FRAME_BUFFER);    /* Enable the LCD */  BSP_LCD_DisplayOn();       /* Select the LCD Foreground layer */  BSP_LCD_SelectLayer(0);  BSP_LCD_Clear(LCD_COLOR_WHITE);    /*##-6- Camera Initialization and start capture ############################*/  /* Initialize the Camera */  BSP_CAMERA_Init(RESOLUTION_R480x272);    /* Start the Camera Capture */  BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);    /*##-7- Run Application ####################################################*/  while (1)  {    /* USB Host Background task */    USBH_Process(&hUSB_Host);        switch(Appli_state)    {    case STORAGE_READY:      CAMERA_Capture();      break;          case STORAGE_IDLE:      break;          }   }}
开发者ID:pierreroth64,项目名称:STM32Cube_FW_F4,代码行数:95,


示例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 LED4, LED5 and LED6 */  BSP_LED_Init(LED4);  BSP_LED_Init(LED5);  BSP_LED_Init(LED6);    /* Configure the system clock to 84 MHz */  SystemClock_Config();  /*##-1- Configure the I2C peripheral ######################################*/  I2cHandle.Instance             = I2Cx;    I2cHandle.Init.AddressingMode  = I2C_ADDRESSINGMODE_10BIT;  I2cHandle.Init.ClockSpeed      = 400000;  I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;  I2cHandle.Init.DutyCycle       = I2C_DUTYCYCLE_16_9;  I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;  I2cHandle.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLE;  I2cHandle.Init.OwnAddress1     = I2C_ADDRESS;  I2cHandle.Init.OwnAddress2     = 0xFE;    if(HAL_I2C_Init(&I2cHandle) != HAL_OK)  {    /* Initialization Error */    Error_Handler();      }  #ifdef MASTER_BOARD    /* Configure User Button */  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);    /* Wait for User Button press before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) != 1)  {  }    /* Wait for User Button release before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) != 0)  {  }    /* The board sends the message and expects to receive it back */    /*##-2- Start the transmission process #####################################*/    /* While the I2C in reception process, user can transmit data through      "aTxBuffer" buffer */  while(HAL_I2C_Master_Transmit_IT(&I2cHandle, (uint16_t)I2C_ADDRESS, (uint8_t*)aTxBuffer, TXBUFFERSIZE)!= HAL_OK)  {    /* Error_Handler() function is called when Timeout error occurs.       When Acknowledge failure occurs (Slave don't acknowledge it's address)       Master restarts communication */    if (HAL_I2C_GetError(&I2cHandle) != HAL_I2C_ERROR_AF)    {      Error_Handler();    }  }    /*##-3- Wait for the end of the transfer ###################################*/    /*  Before starting a new communication transfer, you need to check the current         state of the peripheral; if it’s busy you need to wait for the end of current      transfer before starting a new one.      For simplicity reasons, this example is just waiting till the end of the       transfer, but application may perform other tasks while transfer operation      is ongoing. */    while (HAL_I2C_GetState(&I2cHandle) != HAL_I2C_STATE_READY)  {  }     /* Wait for User Button press before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) != 1)  {  }  /* Wait for User Button release before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) != 0)  {  }      /*##-4- Put I2C peripheral in reception process ############################*/    while(HAL_I2C_Master_Receive_IT(&I2cHandle, (uint16_t)I2C_ADDRESS, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)  {    /* Error_Handler() function is called when Timeout error occurs.       When Acknowledge failure occurs (Slave don't acknowledge it's address)       Master restarts communication *///.........这里部分代码省略.........
开发者ID:451506709,项目名称:automated_machine,代码行数:101,


示例24: StopRTCMode_Measure

/**  * @brief  This function configures the system to enter Stop mode with RTC  *         clocked by LSE or LSI for current consumption measurement purpose.  *         STOP Mode with RTC clocked by LSE/LSI  *         =====================================  *           - RTC Clocked by LSE or LSI  *           - Regulator in LP mode  *           - HSI, HSE OFF and LSI OFF if not used as RTC Clock source  *           - No IWDG  *           - Automatic Wakeup using RTC clocked by LSE/LSI (~20s)  * @param  None  * @retval None  */void StopRTCMode_Measure(void){  GPIO_InitTypeDef GPIO_InitStruct;  /* Configure all GPIO as analog to reduce current consumption on non used IOs */  /* Enable GPIOs clock */  /* Warning : Reconfiguring all GPIO will close the connexion with the debugger */  __HAL_RCC_GPIOA_CLK_ENABLE();  __HAL_RCC_GPIOB_CLK_ENABLE();  __HAL_RCC_GPIOC_CLK_ENABLE();  __HAL_RCC_GPIOD_CLK_ENABLE();  __HAL_RCC_GPIOF_CLK_ENABLE();  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;  GPIO_InitStruct.Pull = GPIO_NOPULL;  GPIO_InitStruct.Pin = GPIO_PIN_All;  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);  HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);  /* Disable GPIOs clock */  __HAL_RCC_GPIOA_CLK_DISABLE();  __HAL_RCC_GPIOB_CLK_DISABLE();  __HAL_RCC_GPIOC_CLK_DISABLE();  __HAL_RCC_GPIOD_CLK_DISABLE();  __HAL_RCC_GPIOF_CLK_DISABLE();  RTCHandle.Instance = RTC;  /* Configure RTC prescaler and RTC data registers as follows:  - Hour Format = Format 24  - Asynch Prediv = Value according to source clock  - Synch Prediv = Value according to source clock  - OutPut = Output Disable  - OutPutPolarity = High Polarity  - OutPutType = Open Drain */  RTCHandle.Init.HourFormat = RTC_HOURFORMAT_24;  RTCHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV;  RTCHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV;  RTCHandle.Init.OutPut = RTC_OUTPUT_DISABLE;  RTCHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;  RTCHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;  if (HAL_RTC_Init(&RTCHandle) != HAL_OK)  {    /* Initialization Error */    Error_Handler();  }  /*## Configure the Wake up timer ###########################################*/  /*  RTC Wakeup Interrupt Generation:      Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI))      Wakeup Time = Wakeup Time Base * WakeUpCounter                   = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) * WakeUpCounter      ==> WakeUpCounter = Wakeup Time / Wakeup Time Base      To configure the wake up timer to 20s the WakeUpCounter is set to 0xA017:        RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16         Wakeup Time Base = 16 /(~32.768KHz) = ~0,488 ms        Wakeup Time = ~20s = 0,488ms  * WakeUpCounter        ==> WakeUpCounter = ~20s/0,488ms = 40983 = 0xA017 */  /* Disable Wake-up timer */  HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);  HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, 0xA017, RTC_WAKEUPCLOCK_RTCCLK_DIV16);  /* Configure User push-button as external interrupt generator */  BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);  /* Enter Stop Mode */  HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);  /* Configures system clock after wake-up from STOP: enable HSI and PLL with HSI as source*/  SystemClock_Config();  /* Disable Wake-up timer */  HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);}
开发者ID:NjordCZ,项目名称:stm32cubef0,代码行数:98,


示例25: main

/**  * @brief  Main program.  * @param  None  * @retval None  */int main(void){  /* STM32L0xx HAL library initialization:       - Configure the Flash prefetch, Flash preread and Buffer 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.       - Low Level Initialization     */  HAL_Init();    /* Configure LED3 */  BSP_LED_Init(LED3);  /* Configure the system clock to 32 Mhz */  SystemClock_Config();  /*##-1- Configure the UART peripheral ######################################*/  /* Put the USART peripheral in the Asynchronous mode (UART Mode) */  /* UART1 configured as follow:      - Word Length = 8 Bits      - Stop Bit = One Stop bit      - Parity = None      - BaudRate = 9600 baud      - Hardware flow control disabled (RTS and CTS signals) */  UartHandle.Instance        = USARTx;  UartHandle.Init.BaudRate   = 9600;  UartHandle.Init.WordLength = UART_WORDLENGTH_8B;  UartHandle.Init.StopBits   = UART_STOPBITS_1;  UartHandle.Init.Parity     = UART_PARITY_NONE;  UartHandle.Init.HwFlowCtl  = UART_HWCONTROL_NONE;  UartHandle.Init.Mode       = UART_MODE_TX_RX;    if(HAL_UART_Init(&UartHandle) != HAL_OK)  {    Error_Handler();  }  #ifdef TRANSMITTER_BOARD  /* Configure Button Key */  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);  /* Toggle led3 waiting for user to press button */  BSP_LED_On(LED3);      /* Wait for Button Key press before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) == RESET)  {		  }  /* Wait for Button Key to be release before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) == SET)  {  }    /* Turn led3 off */  BSP_LED_Off(LED3);    /* The board sends the message and expects to receive it back */    /*##-2- Start the transmission process #####################################*/    /* While the UART in reception process, user can transmit data through      "aTxBuffer" buffer */  if(HAL_UART_Transmit_IT(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE)!= HAL_OK)  {    Error_Handler();  }    /*##-3- Wait for the end of the transfer ###################################*/     while (UartReady != SET)  {  }    /* Reset transmission flag */  UartReady = RESET;    /*##-4- Put UART peripheral in reception process ###########################*/    if(HAL_UART_Receive_IT(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)  {    Error_Handler();  }#else    /* The board receives the message and sends it back */  /*##-2- Put UART peripheral in reception process ###########################*/    if(HAL_UART_Receive_IT(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)  {    Error_Handler();  }  //.........这里部分代码省略.........
开发者ID:pengphei,项目名称:STM32Cube_L0,代码行数:101,


示例26: 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 TAMPER Button */  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);  /*##-1- Initialize the LCD #################################################*/  /* Initialize the LCD */  BSP_LCD_Init();    /* Set LCD font */  BSP_LCD_SetFont(&Font20);     /* LCD Layer Initialization */  BSP_LCD_LayerDefaultInit(1, 0xC0130000);     BSP_LCD_SelectLayer(1);    BSP_LCD_DisplayOn();      /*##-2- Display messages on LCD ############################################*/    /* Clear the LCD */   BSP_LCD_Clear(LCD_COLOR_WHITE);  /* Set the LCD Text Color */  BSP_LCD_SetTextColor(LCD_COLOR_BLUE);    /* Display test name on LCD */    BSP_LCD_DisplayStringAtLine(0,(uint8_t*)"         Flash Write        ");  BSP_LCD_DisplayStringAtLine(1,(uint8_t*)"       protection test      ");  BSP_LCD_DisplayStringAtLine(2,(uint8_t*)"          Press User        ");  BSP_LCD_DisplayStringAtLine(3,(uint8_t*)"      Tamper/Key-button     ");    /* Infinite loop */  while (1)  {    /* Wait for TAMPER/KEY button to be pushed */    while(BSP_PB_GetState(BUTTON_TAMPER) != RESET)    {    }        /* Get FLASH_WRP_SECTORS write protection status */    HAL_FLASHEx_OBGetConfig(&OBInit);    SectorsWRPStatus = OBInit.WRPSector & FLASH_WRP_SECTORS;        if (SectorsWRPStatus == 0)    {      /* If FLASH_WRP_SECTORS are write protected, disable the write protection */            /* Allow Access to option bytes sector */       HAL_FLASH_OB_Unlock();          /* Allow Access to Flash control registers and user Falsh */      HAL_FLASH_Unlock();            /* Disable FLASH_WRP_SECTORS write protection */      OBInit.OptionType = OPTIONBYTE_WRP;      OBInit.WRPState   = OB_WRPSTATE_DISABLE;      OBInit.Banks      = FLASH_BANK_1;      OBInit.WRPSector  = FLASH_WRP_SECTORS;      HAL_FLASHEx_OBProgram(&OBInit);            /* Start the Option Bytes programming process */        if (HAL_FLASH_OB_Launch() != HAL_OK)      {        /* User can add here some code to deal with this error */        while (1)        {        }      }            /* Prevent Access to option bytes sector */       HAL_FLASH_OB_Lock();          /* Disable the Flash option control register access (recommended to protect       the option Bytes against possible unwanted operations) */      HAL_FLASH_Lock();            /* Get FLASH_WRP_SECTORS write protection status */      HAL_FLASHEx_OBGetConfig(&OBInit);      SectorsWRPStatus = OBInit.WRPSector & FLASH_WRP_SECTORS;            /* Check if FLASH_WRP_SECTORS write protection is disabled */      if (SectorsWRPStatus == FLASH_WRP_SECTORS)      {//.........这里部分代码省略.........
开发者ID:PaxInstruments,项目名称:STM32CubeF4,代码行数:101,


示例27: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){  /* STM32F3xx HAL library initialization:       - Configure the Flash prefetch       - 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, LED2, LED3 */  BSP_LED_Init(LED1);  BSP_LED_Init(LED2);  BSP_LED_Init(LED3);  /* Configure the system clock to 72 MHz */  SystemClock_Config();  /* Configure Key push-button */  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);  /*##-1- Check if the system has resumed from WWDG reset ####################*/  if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST) != RESET)  {    /* WWDGRST flag set: Turn LED1 on */    BSP_LED_On(LED1);    /* Clear reset flags */    __HAL_RCC_CLEAR_RESET_FLAGS();  }  else  {    /* WWDGRST flag is not set: Turn LED1 off */    BSP_LED_Off(LED1);  }  /*##-2- Configure the WWDG peripheral ######################################*/  /* WWDG clock counter = (PCLK1 (36MHz)/4096)/8) = 1098 Hz (~910 us)      WWDG Window value = 80 means that the WWDG counter should be refreshed only      when the counter is below 80 (and greater than 64/0x40) otherwise a reset will      be generated.      WWDG Counter value = 127, WWDG timeout = ~910 us * 64 = 58.24 ms */  WwdgHandle.Instance = WWDG;  WwdgHandle.Init.Prescaler = WWDG_PRESCALER_8;  WwdgHandle.Init.Window    = 80;  WwdgHandle.Init.Counter   = 127;  if (HAL_WWDG_Init(&WwdgHandle) != HAL_OK)  {    /* Initialization Error */    Error_Handler();  }  /*##-3- Start the WWDG #####################################################*/  if (HAL_WWDG_Start(&WwdgHandle) != HAL_OK)  {    Error_Handler();  }  /* Infinite loop */  while (1)  {    /* Toggle LED2 */    BSP_LED_Toggle(LED2);    /* Insert 45 ms delay */    HAL_Delay(45);    /* Refresh WWDG: update counter value to 127, the refresh window is: between 42.7ms (~910 * (127-80)) and 58.24 ms (~910 * 64) */    if (HAL_WWDG_Refresh(&WwdgHandle, 127) != HAL_OK)    {      Error_Handler();    }  }}
开发者ID:PaxInstruments,项目名称:STM32CubeF3,代码行数:86,


示例28: 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 LED4, LED6 and LED5 */  BSP_LED_Init(LED4);  BSP_LED_Init(LED6);  BSP_LED_Init(LED5);  /* Configure the system clock to 84 Mhz */  SystemClock_Config();  /*##-1- Configure the I2C peripheral ######################################*/  I2cHandle.Instance             = I2Cx;    I2cHandle.Init.AddressingMode  = I2C_ADDRESSINGMODE_10BIT;  I2cHandle.Init.ClockSpeed      = 400000;  I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;  I2cHandle.Init.DutyCycle       = I2C_DUTYCYCLE_16_9;  I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;  I2cHandle.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLED;  I2cHandle.Init.OwnAddress1     = I2C_ADDRESS;  I2cHandle.Init.OwnAddress2     = 0xFE;    if(HAL_I2C_Init(&I2cHandle) != HAL_OK)  {    /* Initialization Error */    Error_Handler();      }  #ifdef MASTER_BOARD    /* Configure User Button */  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);    /* Wait for User Button press before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) != 1)  {  }    /* Wait for User Button release before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) != 0)  {  }    /* The board sends the message and expects to receive it back */    /*##-2- Start the transmission process #####################################*/    /* While the I2C in reception process, user can transmit data through      "aTxBuffer" buffer */  /* Timeout is set to 10S */  while(HAL_I2C_Master_Transmit(&I2cHandle, (uint16_t)I2C_ADDRESS, (uint8_t*)aTxBuffer, TXBUFFERSIZE, 10000)!= HAL_OK)  {    /* Error_Handler() function is called when Timout error occurs.       When Acknowledge failure ocucurs (Slave don't acknowledge it's address)       Master restarts communication */    if (HAL_I2C_GetError(&I2cHandle) != HAL_I2C_ERROR_AF)    {      Error_Handler();    }  }    /* Turn LED4 on: Transfer in Transmission process is correct */  BSP_LED_On(LED4);    /* Wait for User Button press before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) != 1)  {  }  /* Wait for User Button release before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) != 0)  {  }    /*##-3- Put I2C peripheral in reception process ############################*/   /* Timeout is set to 10S */   while(HAL_I2C_Master_Receive(&I2cHandle, (uint16_t)I2C_ADDRESS, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 10000) != HAL_OK)  {    /* Error_Handler() function is called when Timout error occurs.       When Acknowledge failure ocucurs (Slave don't acknowledge it's address)       Master restarts communication */    if (HAL_I2C_GetError(&I2cHandle) != HAL_I2C_ERROR_AF)    {      Error_Handler();    }     }  /* Turn LED6 on: Transfer in reception process is correct *///.........这里部分代码省略.........
开发者ID:EarnestHein89,项目名称:STM32Cube_FW_F4,代码行数:101,


示例29: 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 LED3 and LED4 */  BSP_LED_Init(LED3);  BSP_LED_Init(LED4);  /* Configure the system clock to 180 MHz */  SystemClock_Config();    /*##-1- Configure the SPI peripheral #######################################*/  /* Set the SPI parameters */  SpiHandle.Instance               = SPIx;  SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;  SpiHandle.Init.Direction         = SPI_DIRECTION_2LINES;  SpiHandle.Init.CLKPhase          = SPI_PHASE_1EDGE;  SpiHandle.Init.CLKPolarity       = SPI_POLARITY_HIGH;  SpiHandle.Init.CRCCalculation    = SPI_CRCCALCULATION_DISABLE;  SpiHandle.Init.CRCPolynomial     = 7;  SpiHandle.Init.DataSize          = SPI_DATASIZE_8BIT;  SpiHandle.Init.FirstBit          = SPI_FIRSTBIT_MSB;  SpiHandle.Init.NSS               = SPI_NSS_SOFT;  SpiHandle.Init.TIMode            = SPI_TIMODE_DISABLE;  #ifdef MASTER_BOARD  SpiHandle.Init.Mode = SPI_MODE_MASTER;#else  SpiHandle.Init.Mode = SPI_MODE_SLAVE;#endif /* MASTER_BOARD */  if(HAL_SPI_Init(&SpiHandle) != HAL_OK)  {    /* Initialization Error */    Error_Handler();  }  #ifdef MASTER_BOARD  /* Configure USER Button */  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);  /* Wait for USER Button press before starting the Communication */  while (BSP_PB_GetState(BUTTON_KEY) != 1)  {    BSP_LED_Toggle(LED3);    HAL_Delay(40);  }      BSP_LED_Off(LED3);#endif /* MASTER_BOARD */  /*##-2- Start the Full Duplex Communication process ########################*/    /* While the SPI in TransmitReceive process, user can transmit data through      "aTxBuffer" buffer & receive data through "aRxBuffer" */  if(HAL_SPI_TransmitReceive_DMA(&SpiHandle, (uint8_t*)aTxBuffer, (uint8_t *)aRxBuffer, BUFFERSIZE) != HAL_OK)  {    /* Transfer error in transmission process */    Error_Handler();  }  /*##-3- Wait for the end of the transfer ###################################*/    /*  Before starting a new communication transfer, you need to check the current         state of the peripheral; if it’s busy you need to wait for the end of current      transfer before starting a new one.      For simplicity reasons, this example is just waiting till the end of the       transfer, but application may perform other tasks while transfer operation      is ongoing. */    while (HAL_SPI_GetState(&SpiHandle) != HAL_SPI_STATE_READY)  {  }   /*##-4- Compare the sent and received buffers ##############################*/  if(Buffercmp((uint8_t*)aTxBuffer, (uint8_t*)aRxBuffer, BUFFERSIZE))  {    /* Transfer error in transmission process */    Error_Handler();  }  /* Infinite loop */  while (1)  {  }}
开发者ID:AMMayberry1,项目名称:hongtao_imager,代码行数:94,



注:本文中的BSP_PB_Init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ BSP_SDRAM_Init函数代码示例
C++ BSP_LED_Toggle函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。