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

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

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

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

在下文中一共展示了BSP_LED_Toggle函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();    /* Initialize LEDs */    BSP_LED_Init(LED1);    BSP_LED_Init(LED2);    BSP_LED_Init(LED3);    BSP_LED_Init(LED4);    /* Configure the system clock to have a system clock = 48 MHz */    SystemClock_Config();    /* Turn on LED1 and LED3 */    BSP_LED_On(LED1);    BSP_LED_On(LED3);    /* SysTick Timer is configured by default to generate an interrupt each 1 msec.       ---------------------------------------------------------------------------      1. The configuration is done using HAL_SYSTICK_Config() located in HAL_Init().      2. The HAL_SYSTICK_Config() function configure:         - The SysTick Reload register with value passed as function parameter.         - Configure the SysTick IRQ priority to the lowest value.         - Reset the SysTick Counter register.         - Configure the SysTick Counter clock source to be Core Clock Source (HCLK).         - Enable the SysTick Interrupt.         - Start the SysTick Counter.      3. The SysTick time base 1 msec is computed using the following formula:           Reload Value = SysTick Counter Clock (Hz) x  Desired Time base (s)         - Reload Value is the parameter to be passed for SysTick_Config() function         - Reload Value should not exceed 0xFFFFFF      @note: Caution, the SysTick time base 1 msec must not be changed due to use             of these time base by HAL driver.    */    /* Infinite loop */    while (1)    {        /* Toggle LED2 and LED4 */        BSP_LED_Toggle(LED2);        BSP_LED_Toggle(LED4);        /* Insert 50 ms delay */        HAL_Delay(50);        /* Toggle LED1 and LED3 */        BSP_LED_Toggle(LED1);        BSP_LED_Toggle(LED3);        /* Insert 100 ms delay */        HAL_Delay(100);    }}
开发者ID:jmoyerman,项目名称:stm32f0_cube,代码行数:72,


示例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 LED2, LED2 and LED2 */  BSP_LED_Init(LED2);  /* 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 push button */  BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO);  /* Wait for Button press before starting the Communication */  while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_RESET)  {    BSP_LED_Toggle(LED2);    HAL_Delay(100);  }  BSP_LED_Off(LED2);#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" */  /* Timeout is set to 5S */    switch(HAL_SPI_TransmitReceive(&SpiHandle, (uint8_t*)aTxBuffer, (uint8_t *)aRxBuffer, BUFFERSIZE, 5000))  {    case HAL_OK:      /* Communication is completed ___________________________________________ */      /* Compare the sent and received buffers */      if (Buffercmp((uint8_t *)aTxBuffer, (uint8_t *)aRxBuffer, BUFFERSIZE))      {        /* Transfer error in transmission process */        Error_Handler();      }      /* Turn LED2 on: Transfer in transmission/Reception process is correct */      BSP_LED_On(LED2);      break;    case HAL_TIMEOUT:      /* An Error Occur ______________________________________________________ */    case HAL_ERROR:      /* Call Timeout Handler */      Error_Handler();      break;    default:      break;  }  /* Infinite loop */  while (1)  {  }}
开发者ID:jmoyerman,项目名称:stm32f0_cube,代码行数:98,


示例3: HAL_I2C_SlaveRxCpltCallback

void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *I2cHandle){  /* Toggle LED2: Transfer in reception process is correct */  BSP_LED_Toggle(LED2);}
开发者ID:jmoyerman,项目名称:stm32f0_cube,代码行数:5,


示例4: main

//.........这里部分代码省略.........  UartHandle.Init.HwFlowCtl    = UART_HWCONTROL_NONE;  UartHandle.Init.Mode         = UART_MODE_TX_RX;  UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;      if(HAL_UART_Init(&UartHandle) != HAL_OK)  {    Error_Handler();  }  #ifdef TRANSMITTER_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) == RESET)  {  }    /* 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;  /* Turn LED3 Off */  BSP_LED_Off(LED3);    /*##-4- Put UART peripheral in reception process ###########################*/    if(HAL_UART_Receive_DMA(&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_DMA(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)  {    Error_Handler();  }    /*##-3- Wait for the end of the transfer ###################################*/    while (UartReady != SET)  {  }  /* Reset transmission flag */  UartReady = RESET;    /* Turn LED3 Off */  BSP_LED_Off(LED3);    /*##-4- 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();  }  #endif /* TRANSMITTER_BOARD */    /*##-5- Wait for the end of the transfer ###################################*/    while (UartReady != SET)  {  }    /* Reset transmission flag */  UartReady = RESET;  /*##-6- Compare the sent and received buffers ##############################*/  if(Buffercmp((uint8_t*)aTxBuffer,(uint8_t*)aRxBuffer,RXBUFFERSIZE))  {    Error_Handler();  }  /* Infinite loop */  while (1)  {    /* Toggle LED3 */    BSP_LED_Toggle(LED3);        /* Wait for 40ms */    HAL_Delay(40);  }}
开发者ID:z80,项目名称:stm32f429,代码行数:101,


示例5: HAL_COMP_TriggerCallback

/**  * @brief  COMP1 interrupt callback  * @param  hcomp : COMP handle   * @retval none  */void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp){  /* Turn On LED1 */  BSP_LED_Toggle(LED1);}
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:10,


示例6: main

//.........这里部分代码省略.........    /*##-7- Master receives aRxBuffer from slave #############################*/    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.         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();      }    }    /*  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)    {    }    /* Check correctness of received buffer ##################################*/    if(Buffercmp((uint8_t*)aTxBuffer,(uint8_t*)aRxBuffer,hRxNumData))    {      /* Processing Error */      Error_Handler();    }    /* Flush Rx buffers */    Flush_Buffer((uint8_t*)aRxBuffer,RXBUFFERSIZE);    /* Toggle LED1 */    BSP_LED_Toggle(LED1);    /* This delay permit the key to see LED3 toggling */    HAL_Delay(25);  }#else  while(1)  {    /* Initialize number of data variables */    hTxNumData = 0;    hRxNumData = 0;    /*##-2- Slave receive request from master ################################*/    while(HAL_I2C_Slave_Receive_IT(&I2cHandle, (uint8_t*)&bTransferRequest, 1)!= HAL_OK)    {    }    /*  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)    {    }    /* If master request write operation #####################################*/    if (bTransferRequest == MASTER_REQ_WRITE)    {      /*##-3- Slave receive number of data to be read ########################*/      while(HAL_I2C_Slave_Receive_IT(&I2cHandle, (uint8_t*)&hRxNumData, 2)!= HAL_OK);
开发者ID:PaxInstruments,项目名称:STM32CubeF3,代码行数:66,


示例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 LED3 and LED4 and User push-button */    BSP_LED_Init(LED3);    BSP_LED_Init(LED4);    BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);    /* Configure the system clock to 48 MHz */    SystemClock_Config();    /*##-1- Check if the system has resumed from WWDG reset ####################*/    if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST) != RESET)    {        /* WWDGRST flag set: Turn LED3 on */        BSP_LED_On(LED3);        /* Clear reset flags */        __HAL_RCC_CLEAR_RESET_FLAGS();    }    else    {        /* WWDGRST flag is not set: Turn LED3 off */        BSP_LED_Off(LED3);    }    /*##-2- Configure the WWDG peripheral ######################################*/    /* WWDG clock counter = (PCLK1 (48MHz)/4096)/8) = 1464.8 Hz (~683 us)       WWDG Window value = 80 means that the WWDG counter should be refreshed only       when the counter is below 80 (and greater than 64 (63+1)) otherwise a reset will       be generated.       WWDG Counter value = 127, WWDG timeout = ~683 us * 64 = 43.7 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 LED4 */        BSP_LED_Toggle(LED4);        /* Insert 40 ms delay */        HAL_Delay(40);        /* Refresh WWDG: update counter value to 127, the refresh window is:        refresh window between 32.1ms (~683 * (127-80)) and 43.7ms (~683 * 64) */        if (HAL_WWDG_Refresh(&WwdgHandle, 127) != HAL_OK)        {            Error_Handler();        }    }}
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:84,


示例8: ssl_client

//.........这里部分代码省略.........  {    printf( " failed/n/r" );        if( ( ret & BADCERT_EXPIRED ) != 0 )      printf( "  ! server certificate has expired/n" );        if( ( ret & BADCERT_REVOKED ) != 0 )      printf( "  ! server certificate has been revoked/n" );        if( ( ret & BADCERT_CN_MISMATCH ) != 0 )      printf( "  ! CN mismatch (expected CN=%s)/n", "PolarSSL Server 1" );        if( ( ret & BADCERT_NOT_TRUSTED ) != 0 )      printf( "  ! self-signed or not signed by a trusted CA/n" );        printf( "/n/r" );  }  else    printf( " ok/n/r" );    /*  * Write the GET request  */  printf( "  > Write to server:" );    len = sprintf( (char *) buf, GET_REQUEST );    while( ( ret = ssl_write( &ssl, buf, len ) ) <= 0 )  {    if( ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE )    {      printf( " failed/n  ! ssl_write returned %d/n/n/r", ret );      goto exit;    }  }    len = ret;  printf( " %d bytes written/n/n/r%s", len, (char *) buf );    /*  * Read the HTTP response  */  printf( "  < Read from server:" );    do  {    len = sizeof( buf ) - 1;    memset( buf, 0, sizeof( buf ) );    ret = ssl_read( &ssl, buf, len );        if( ret == POLARSSL_ERR_NET_WANT_READ || ret == POLARSSL_ERR_NET_WANT_WRITE )      continue;        if( ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY )      break;        if( ret < 0 )    {      printf( "failed/n/r  ! ssl_read returned %d/n/n/r", ret );      break;    }        if( ret == 0 )    {      printf( "/n/nEOF/n/n/r" );      break;    }        len = ret;    printf( " %d bytes read/n/n/r%s", len, (char *) buf );  }  while( 1 );  exit:#ifdef POLARSSL_ERROR_C  if( ret != 0 )  {    char error_buf[100];    error_strerror( ret, error_buf, 100 );    printf("Last error was: %d - %s/n/n/r", ret, error_buf );  }#endif    x509_free( &cacert );  net_close( server_fd );  ssl_free( &ssl );    memset( &ssl, 0, sizeof( ssl ) );    /* Infinite loop */  for( ;; )   {    /* Toggle LED1 */    BSP_LED_Toggle(LED1);        /* Insert 400 ms delay */    osDelay(400);  }}
开发者ID:PaxInstruments,项目名称:STM32CubeF2,代码行数:101,


示例9: 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_KEY, 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_KEY) != 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 (Key Button PE.06)    */    SleepMode_Measure();#elif defined (STOP_MODE)    /* STOP Mode Entry //.........这里部分代码省略.........
开发者ID:eleciawhite,项目名称:STM32Cube,代码行数:101,


示例10: HAL_PWR_PVDCallback

/**  * @brief  PWR PVD interrupt callback  * @param  none   * @retval none  */void HAL_PWR_PVDCallback(void){  /* Toggle LED1 */  BSP_LED_Toggle(LED1);}
开发者ID:EarnestHein89,项目名称:STM32Cube_FW_F4,代码行数:10,


示例11: FW_UPGRADE_Process

/**  * @brief  Demo application for IAP through USB mass storage.  * @param  None  * @retval None  */void FW_UPGRADE_Process(void){    switch(Demo_State)    {    case DEMO_INIT:        /* Register the file system object to the FatFs module */        if(f_mount(&USBH_fatfs, "", 0 ) != FR_OK )        {            /* FatFs initialization fails */            /* Toggle LED3 and LED4 in infinite loop */            FatFs_Fail_Handler();        }        /* TO DO */        //    /* Flash Disk is write protected: Turn LED4 On and Toggle LED3 in infinite loop */        //    if(USBH_MSC_Param.MSWriteProtect == DISK_WRITE_PROTECTED)        //    {        //      /* Turn LED4 On */        //      BSP_LED_On(LED4);        //      /* Toggle LED3 in infinite loop */        //      Fail_Handler();        //    }        /* Go to IAP menu */        Demo_State = DEMO_IAP;        break;    case DEMO_IAP:        while(USBH_MSC_IsReady(&hUSBHost))        {            /* Control BUFFER_SIZE value */            USBH_USR_BufferSizeControl();            /* Keep LED1 and LED3 Off when Device connected */            BSP_LED_Off(LED3);            BSP_LED_Off(LED4);            /* USER Button pressed Delay */            IAP_UploadTimeout();            /* Writes Flash memory */            COMMAND_Download();            /* Check if USER Button is already pressed */            if((UploadCondition == 0x01))            {                /* Reads all flash memory */                COMMAND_Upload();            }            else            {                /* Turn LED4 Off: Download Done */                BSP_LED_Off(LED4);                /* Turn LED3 On: Waiting KEY button pressed */                BSP_LED_On(LED3);            }            /* Waiting USER Button Released */            while((BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET) && (Appli_state == APPLICATION_READY))            {}            /* Waiting USER Button Pressed */            while((BSP_PB_GetState(BUTTON_KEY) != GPIO_PIN_RESET) && (Appli_state == APPLICATION_READY))            {}            /* Waiting USER Button Released */            while((BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET) && (Appli_state == APPLICATION_READY))            {}            if(Appli_state == APPLICATION_READY)            {                /* Jump to user application code located in the internal Flash memory */                COMMAND_Jump();            }        }        break;    default:        break;    }    if(Appli_state == APPLICATION_DISCONNECT)    {        /* Toggle LED3: USB device disconnected */        BSP_LED_Toggle(LED4);        HAL_Delay(100);    }}
开发者ID:eemei,项目名称:library-stm32f4,代码行数:93,


示例12: 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 48 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(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE, 5000)!= HAL_OK)  {    Error_Handler();     }      /*##-3- Put UART peripheral in reception process ###########################*/    if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 5000) != 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(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 0x1FFFFFF) != HAL_OK)  {    Error_Handler();  }     /*##-3- Start the transmission process #####################################*/    /* While the UART in reception process, user can transmit data through //.........这里部分代码省略.........
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:101,


示例13: 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 LED */  BSP_LED_Init(LED2);   /* Configure the system clock to 48 MHz */  SystemClock_Config();  /* Enable Power Clock */  __HAL_RCC_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 LED2 and keep        it on for 2 sec. to indicate       exit from stand-by mode */    BSP_LED_On(LED2);    while(BSP_PB_GetState(BUTTON_USER) == GPIO_PIN_RESET){}    HAL_Delay(2000);    uwStandByOutFlag = 1;  }  /* 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, LED2 is blinks */    while (UserButtonStatus == 0)    {      /* Toggle LED2 */      BSP_LED_Toggle(LED2);       HAL_Delay(100);    }    /* Make sure LED2 is turned off to        reduce low power mode consumption */    BSP_LED_Off(LED2);#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 PC.13)    */    SleepMode_Measure();#elif defined (STOP_RTC_MODE)    /* STOP Mode Entry     - RTC Clocked by LSI or LSE    - 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 LSI (after ~20s)    - Wakeup using EXTI Line (User push-button PC.13)    */    StopRTCMode_Measure();#elif defined (STANDBY_MODE)    /* STANDBY Mode Entry        - RTC OFF        - IWDG and LSI OFF        - Wakeup using WakeUp Pin PWR_WAKEUP_PIN2 connected to PC.13    */    StandbyMode_Measure();#elif defined (STANDBY_RTC_MODE)    /* STANDBY Mode with RTC on LSE/LSI Entry        - RTC Clocked by LSE or LSI        - IWDG OFF and LSI OFF if not used as RTC Clock source        - Automatic Wakeup using RTC clocked by LSE/LSI (after ~20s)//.........这里部分代码省略.........
开发者ID:jmoyerman,项目名称:stm32f0_cube,代码行数:101,


示例14: 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 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 User push-button */  BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO);  /* Wait for User push-button press before starting the Communication */  while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_RESET)  {    BSP_LED_Toggle(LED2);    HAL_Delay(40);  }  BSP_LED_Off(LED2);#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:jmoyerman,项目名称:stm32f0_cube,代码行数:96,


示例15: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){  uint32_t index = 0;  RTC_TamperTypeDef  stamperstructure;    /* 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();  /* Configure LED1 and LED3 */  BSP_LED_Init(LED1);  BSP_LED_Init(LED3);  /* Configure User push-button button */  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);    /*##-1- Configure the RTC peripheral #######################################*/  /* Configure RTC prescaler and RTC data registers */  /* RTC configured 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.Instance            = RTC;  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();  }  /*##-2- Configure RTC Tamper ###############################################*/  stamperstructure.Tamper                       = RTC_TAMPER_1;  /* Use PC13 as Tamper 1 with interrupt mode */  stamperstructure.PinSelection                 = RTC_TAMPERPIN_PC13;  stamperstructure.Trigger                      = RTC_TAMPERTRIGGER_FALLINGEDGE;  stamperstructure.Filter                       = RTC_TAMPERFILTER_DISABLE;  stamperstructure.SamplingFrequency            = RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768;  stamperstructure.PrechargeDuration            = RTC_TAMPERPRECHARGEDURATION_1RTCCLK;  stamperstructure.TamperPullUp                 = RTC_TAMPER_PULLUP_ENABLE;  stamperstructure.TimeStampOnTamperDetection   = RTC_TIMESTAMPONTAMPERDETECTION_DISABLE;  if (HAL_RTCEx_SetTamper_IT(&RtcHandle, &stamperstructure) != HAL_OK)  {    /* Initialization Error */    Error_Handler();  }  /* Clear the Tamper interrupt pending bit */  __HAL_RTC_TAMPER_CLEAR_FLAG(&RtcHandle,RTC_FLAG_TAMP1F);  /*##-3- Write Data on the Back Up registers ################################*/  for (index = 0; index < BACKUP_COUNT; index++)  {    HAL_RTCEx_BKUPWrite(&RtcHandle, aBKPDataReg[index], 0xDF59 + (index * 0x5A));  }  /*##-4- Check Data is stored on the Back Up registers ######################*/  for (index = 0; index < BACKUP_COUNT; index++)  {    if (HAL_RTCEx_BKUPRead(&RtcHandle, aBKPDataReg[index]) != (0xDF59 + (index * 0x5A)))    {      Error_Handler();    }  }  /*##-5- Wait for the tamper button is pressed ##############################*/  while (TamperStatus != SET)  {    /* Toggle LED1 with a period of 1s */    BSP_LED_Toggle(LED1);    /* Delay */    HAL_Delay(1000);  }//.........这里部分代码省略.........
开发者ID:z80,项目名称:stm32f429,代码行数: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();    /*******************************************************************************  *                          Common Configuration Routines                       *  *******************************************************************************/    /* Configure LED2 and Key Button */  BSP_LED_Init(LED2);  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);  /* Configure the system clock to 32 Mhz */  SystemClock_Config();         /*##-1- Check if the system has resumed from IWDG reset ####################*/  if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET)  {     /* IWDGRST flag set: Turn LED2 on */    BSP_LED_On(LED2);    /* Insert 4s delay */    HAL_Delay(4000);        /* Clear reset flags */    __HAL_RCC_CLEAR_RESET_FLAGS();  }  else  {    /* IWDGRST flag is not set: Turn LED2 off */    BSP_LED_Off(LED2);  }   /*##-2- Get the LSI frequency: TIM21 is used to measure the LSI frequency ###*/  uwLsiFreq = GetLSIFrequency();    /*##-3- Configure & Initialize the IWDG peripheral ######################################*/  /* Set counter reload value to obtain 250ms IWDG TimeOut.     IWDG counter clock Frequency = LsiFreq/32     Counter Reload Value = 250ms/IWDG counter clock period                          = 0.25s / (32/LsiFreq)                          = LsiFreq/(32 * 4)                          = LsiFreq/128 */  IwdgHandle.Instance = IWDG;  IwdgHandle.Init.Prescaler = IWDG_PRESCALER_32;  IwdgHandle.Init.Reload = uwLsiFreq/128;  IwdgHandle.Init.Window = IWDG_WINDOW_DISABLE;  if(HAL_IWDG_Init(&IwdgHandle) != HAL_OK)  {    /* Initialization Error */    Error_Handler();  }    /*##-4- Start the IWDG #####################################################*/   if(HAL_IWDG_Start(&IwdgHandle) != HAL_OK)  {    Error_Handler();  }    /* Infinite loop */   while (1)  {    /* Toggle LED2 */    BSP_LED_Toggle(LED2);    /* Insert 240 ms delay */    HAL_Delay(240);    /* Refresh IWDG: reload counter */    if(HAL_IWDG_Refresh(&IwdgHandle) != HAL_OK)    {      /* Refresh Error */      Error_Handler();    }  }}
开发者ID:shjere,项目名称:common,代码行数:92,


示例17: HAL_TIM_PeriodElapsedCallback

/**  * @brief  Period elapsed callback in non blocking mode  * @param  htim : TIM handle  * @retval None  */void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){  BSP_LED_Toggle(LED1);}
开发者ID:eemei,项目名称:library-stm32f4,代码行数:9,


示例18: main

/**  * @brief  Main program  * @param  None  * @retval None  */int main(void){#ifdef TRANSMITTER_BOARD  GPIO_InitTypeDef  GPIO_InitStruct;#endif  /* 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 LED3 */  BSP_LED_Init(LED3);#ifdef TRANSMITTER_BOARD  /* Configure PA.12 (Arduino D2) as input with External interrupt */  GPIO_InitStruct.Pin = GPIO_PIN_12;  GPIO_InitStruct.Pull = GPIO_PULLUP;  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;  /* Enable GPIOA clock */  __HAL_RCC_GPIOA_CLK_ENABLE();  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);  /* Enable and set PA.12 (Arduino D2) EXTI Interrupt to the lowest priority */  NVIC_SetPriority((IRQn_Type)(EXTI4_15_IRQn), 0x03);  HAL_NVIC_EnableIRQ((IRQn_Type)(EXTI4_15_IRQn));  /* Wait for the user to set GPIOA to GND before starting the Communication.     In the meantime, LED3 is blinking */  while(VirtualUserButtonStatus == 0)  {      /* Toggle LED3*/      BSP_LED_Toggle(LED3);      HAL_Delay(100);  }  BSP_LED_Off(LED3);#endif  /*##-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    /* The board sends the message and expects to receive it back */  /* DMA is programmed for reception before starting the transmission, in order to     be sure DMA Rx is ready when board 2 will start transmitting */  /*##-2- Program the Reception process #####################################*/    if(HAL_UART_Receive_DMA(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)  {    Error_Handler();  }  /*##-3- 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();  }    /*##-4- Wait for the end of the transfer ###################################*/  //.........这里部分代码省略.........
开发者ID:NjordCZ,项目名称:stm32cubef0,代码行数:101,


示例19: 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 and LED6 */  BSP_LED_Init(LED3);  BSP_LED_Init(LED4);  BSP_LED_Init(LED5);  BSP_LED_Init(LED6);    /* Configure USER Button, used to trigger an interrupt each time it's pressed.     In the ISR the PLL source will be changed from HSE to HSI, and vice versa. */  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);    /* Enable Power Control clock */  __HAL_RCC_PWR_CLK_ENABLE();  /* The voltage scaling allows optimizing the power consumption when the device is      clocked below the maximum system frequency, to update the voltage scaling value      regarding system frequency refer to product datasheet.  */  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);     /* Enable HSE oscillator and configure the PLL to reach the max system frequency (168MHz)     when using HSE oscillator as PLL clock source. */  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;  RCC_OscInitStruct.HSEState = RCC_HSE_ON;  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;  RCC_OscInitStruct.PLL.PLLM = 8;  RCC_OscInitStruct.PLL.PLLN = 336;  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;  RCC_OscInitStruct.PLL.PLLQ = 7;  if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)  {    /* Initialization Error */    Error_Handler();  }    /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers.     The SysTick 1 msec interrupt is required for the HAL process (Timeout management); by default     the configuration is done using the HAL_Init() API, and when the system clock configuration     is updated the SysTick configuration will be adjusted by the HAL_RCC_ClockConfig() API. */  RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;    RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;    if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)  {    /* Initialization Error */    Error_Handler();  }  /* STM32F405x/407x/415x/417x Revision Z devices: prefetch is supported  */  if (HAL_GetREVID() == 0x1001)  {    /* Enable the Flash prefetch */    __HAL_FLASH_PREFETCH_BUFFER_ENABLE();  }  /* Output SYSCLK divided by 2 on MCO2 pin(PC9) */   HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_2);  /* Toggle some LEDs in an infinite loop */    while (1)  {   /* Toggle LED3 */    BSP_LED_Toggle(LED3);    HAL_Delay(100);    /* Toggle LED4 */    BSP_LED_Toggle(LED4);    HAL_Delay(100);    /* Toggle LED6 */    BSP_LED_Toggle(LED6);    HAL_Delay(100);  }}
开发者ID:z80,项目名称:stm32f429,代码行数:88,


示例20: main

//.........这里部分代码省略.........  /* 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(LED2);  BSP_LED_On(LED3);  BSP_LED_On(LED4);    /* Initialize the Audio codec and all related peripherals (SAI, I2C, IOs...) */    if(AUDIO_Init() == AUDIO_ERROR_NONE)  {    BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"====================", CENTER_MODE);    BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"Tamper: Vol+        ", CENTER_MODE);    BSP_LCD_DisplayStringAt(0, LINE(6), (uint8_t *)"Wakeup: Vol-        ", CENTER_MODE);    BSP_LCD_DisplayStringAt(0, LINE(7), (uint8_t *)"====================", CENTER_MODE);    BSP_LCD_DisplayStringAt(0, LINE(8), (uint8_t *)"  AUDIO CODEC   OK  ", CENTER_MODE);      }  else  {    BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"  AUDIO CODEC  FAIL ", CENTER_MODE);    BSP_LCD_DisplayStringAt(0, LINE(5), (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(9), (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)  {          /* Check on the Volume high button */    if (BSP_PB_GetState(BUTTON_WAKEUP) != RESET)    {      /* Wait to avoid rebound */      while (BSP_PB_GetState(BUTTON_WAKEUP) != RESET);            /* Decrease volume by 5% */      if (uwVolume > 5)        uwVolume -= 5;       else        uwVolume = 0;             /* Apply the new volume to the codec */      BSP_AUDIO_OUT_SetVolume(uwVolume);      BSP_LCD_DisplayStringAt(0, LINE(10), (uint8_t *)"       VOL:   -     ", CENTER_MODE);     }            /* Check on the Volume high button */    if (BSP_PB_GetState(BUTTON_TAMPER) == RESET)    {      /* Wait to avoid rebound */      while (BSP_PB_GetState(BUTTON_TAMPER) == RESET);            /* Increase volume by 5% */      if (uwVolume < 95)        uwVolume += 5;       else        uwVolume = 100;             /* Apply the new volume to the codec */      BSP_AUDIO_OUT_SetVolume(uwVolume);      BSP_LCD_DisplayStringAt(0, LINE(10), (uint8_t *)"       VOL:   +     ", CENTER_MODE);    }          /* Toggle LED3 */    BSP_LED_Toggle(LED3);        /* Insert 100 ms delay */    HAL_Delay(100);        /* Toggle LED2 */    BSP_LED_Toggle(LED2);        /* Insert 100 ms delay */    HAL_Delay(100);  } }
开发者ID:pierreroth64,项目名称:STM32Cube_FW_F4,代码行数:101,


示例21: client_request_time

/* Funzione: client_request_time(uint8_t client_id) * Parametri: client_id: id del nodo che effettua la richiesta * @brief : chiede all'host di sincronizzare gli orologi * * */void client_request_time(uint8_t client_id){	sys_time temp;	suspend_time();	uint32_t send_tick = HAL_GetTick();	//network_level_request_time(client_id, &temp);	uint32_t receive_tick = HAL_GetTick();	uint16_t delay = (receive_tick - send_tick) / 2;	uint16_t old_millis = temp.milliseconds;	temp.milliseconds += delay;	if(old_millis < temp.milliseconds){		_sys_time.milliseconds = old_millis-temp.milliseconds;					if (++_sys_time.seconds % 60 == 0) { /*Incrementa secondi. Se sono arrivati a 60 ==> ho contato 1 minuto*/						BSP_LED_Toggle(LED5);						_sys_time.seconds = 0;						if (++_sys_time.minutes % 60 == 0) { /*Incrementa minuti. Se sono arrivati a 60 ==> ho contato 1 ora*/							_sys_time.minutes = 0;							if (++_sys_time.hour % 24 == 0) { /*Incrementa ore. Se sono arrivate a 24 ==> ho contato 1 giorno*/								BSP_LED_Toggle(LED3);								_sys_time.hour = 0;								_sys_time.day++; /*Incrementa giorni.*/								/*Controlla valore del giorno a seconda del mese per capire se si deve incrementare il mese*/								if (((_sys_time.month & 1) && (_sys_time.month < 8)) || //gennaio, marzo, maggio ,luglio,										(!(_sys_time.month & 1)												&& (_sys_time.month >= 8))) { //agosto, ottobre, dicembre									if (_sys_time.day % 32 == 0) {										_sys_time.day = 1;										_sys_time.month++;									}								} else if (_sys_time.month == 2) {			//febbraio									if (_sys_time.day % 29 == 0) {										_sys_time.day = 1;										_sys_time.month++;									}								} else {									if (_sys_time.day % 31 == 0) {		//restanti mesi										_sys_time.day = 1;										_sys_time.month++;									}								}								if (_sys_time.month % 13 == 0) {//Se i mesi sono arrivati a 12 ==> ho contato un anno									_sys_time.month = 1;									_sys_time.year++;								}							}						}					}				}	start_time();}
开发者ID:ing-raf,项目名称:DistributeClock,代码行数:76,


示例22: BlueNRG_Init

static void BlueNRG_Init(){  int rc;  uint8_t bdaddr[] = {0x12, 0x34, 0x00, 0xE1, 0x80, 0x02};  uint16_t service_handle, dev_name_char_handle, appearance_char_handle;  const char *ble_name = "BlueNRG";  BSP_LED_On(LED3);  HCI_Init();  /* Enable and set EXTI for BlueNRG IRQ */  HAL_NVIC_SetPriority(BLUENRG_IRQ_EXTI_IRQn, 2, 0);  HAL_NVIC_EnableIRQ(BLUENRG_IRQ_EXTI_IRQn);  BlueNRG_RST();  BSP_LED_On(LED4);  rc = aci_hal_write_config_data(CONFIG_DATA_PUBADDR_OFFSET,                                 CONFIG_DATA_PUBADDR_LEN, bdaddr);  while (rc) {    HAL_Delay(100);    BSP_LED_Toggle(LED4);  }  BSP_LED_On(LED5);  rc = aci_gatt_init();  while (rc) {    HAL_Delay(100);    BSP_LED_Toggle(LED5);  }  BSP_LED_On(LED6);  rc = aci_gap_init(1, &service_handle, &dev_name_char_handle,                    &appearance_char_handle);  while (rc) {    HAL_Delay(100);    BSP_LED_Toggle(LED6);  }  BSP_LED_Off(LED3);  rc = aci_gatt_update_char_value(service_handle, dev_name_char_handle,                                  0, strlen(ble_name), (uint8_t *)ble_name);  while (rc) {    HAL_Delay(100);    BSP_LED_Toggle(LED3);  }  BSP_LED_Off(LED4);  rc = aci_gap_set_auth_requirement(MITM_PROTECTION_REQUIRED,                                    OOB_AUTH_DATA_ABSENT,                                    NULL,                                    7,                                    16,                                    USE_FIXED_PIN_FOR_PAIRING,                                    123456,                                    BONDING);  while (rc) {    HAL_Delay(100);    BSP_LED_Toggle(LED4);  }  /* sensors have been initialized in HW_Init() */  BSP_LED_Off(LED5);  rc = Add_Acc_Service();  while (rc) {    HAL_Delay(100);    BSP_LED_Toggle(LED5);  }  BSP_LED_Off(LED6);  rc = Add_Environmental_Sensor_Service();  while (rc) {    HAL_Delay(100);    BSP_LED_Toggle(LED6);  }  /* Init_User_Timer();  Start_User_Timer(); */  BSP_LED_On(LED3);  /* -2 dBm output power */  rc = aci_hal_set_tx_power_level(1, 4);  while (rc) {    HAL_Delay(100);    BSP_LED_Toggle(LED3);  }}
开发者ID:andreiung,项目名称:stm32f4-bluenrg,代码行数:88,


示例23: Time_SYSTICK_Callback

/* Funzione: Time_SYSTICK_Callback(void) * @brief : callback per il systick che incrementa, sulla base del tick di sitema, l'orologio * * */void Time_SYSTICK_Callback(void) {	if (is_time_enabled()) {		BSP_LED_Toggle(LED4);		if (++_sys_time.milliseconds % 1000 == 0) { /*Incrementa millisecondi. Se sono arrivati a 1000 ==> ho contato 1 secondo*/			BSP_LED_Toggle(LED6);#if TIME_SERVER==0			_count++;#endif			_sys_time.milliseconds = 0;			if (++_sys_time.seconds % 60 == 0) { /*Incrementa secondi. Se sono arrivati a 60 ==> ho contato 1 minuto*/				BSP_LED_Toggle(LED5);				_sys_time.seconds = 0;				if (++_sys_time.minutes % 60 == 0) { /*Incrementa minuti. Se sono arrivati a 60 ==> ho contato 1 ora*/					_sys_time.minutes = 0;					if (++_sys_time.hour % 24 == 0) { /*Incrementa ore. Se sono arrivate a 24 ==> ho contato 1 giorno*/						BSP_LED_Toggle(LED3);						_sys_time.hour = 0;						_sys_time.day++; /*Incrementa giorni.*/						/*Controlla valore del giorno a seconda del mese per capire se si deve incrementare il mese*/						if (((_sys_time.month & 1) && (_sys_time.month < 8)) || //gennaio, marzo, maggio ,luglio,								(!(_sys_time.month & 1)										&& (_sys_time.month >= 8))) { //agosto, ottobre, dicembre							if (_sys_time.day % 32 == 0) {								_sys_time.day = 1;								_sys_time.month++;							}						} else if (_sys_time.month == 2) {			//febbraio							if (_sys_time.day % 29 == 0) {								_sys_time.day = 1;								_sys_time.month++;							}						} else {							if (_sys_time.day % 31 == 0) {		//restanti mesi								_sys_time.day = 1;								_sys_time.month++;							}						}						if (_sys_time.month % 13 == 0) {//Se i mesi sono arrivati a 12 ==> ho contato un anno							_sys_time.month = 1;							_sys_time.year++;						}					}				}			}		}	}#if TIME_SERVER == 0	if( _count == _timeout ){		_count = 0;		//signal(timeout)	}#endif} // end callback
开发者ID:ing-raf,项目名称:DistributeClock,代码行数:75,


示例24: AudioRec_demo

//.........这里部分代码省略.........#ifdef JOYSTICK    /* Get the Joystick State */    JoyState = BSP_JOY_GetState();    switch (JoyState)    {      case JOY_SEL:#endif        if (AudioRec_State == REC_RESET_STATE)        {          /* Display the state on the screen */          BSP_LCD_SetBackColor(LCD_COLOR_WHITE);          BSP_LCD_SetTextColor(LCD_COLOR_BLUE);          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 80, (uint8_t *)"       RECORDING...     ", CENTER_MODE);          /* Start Recording */          buffer_ctl.rec_length = 0;          buffer_ctl.wr_state = BUFFER_EMPTY;          buffer_ctl.it_state = TRANSFER_NONE;          BSP_AUDIO_IN_Record((uint16_t*)&buffer_ctl.pdm_buff[0], INTERNAL_BUFF_SIZE);          AudioRec_State = RECORD_ONGOING;        }#ifdef JOYSTICK        break;      default:        break;    }#endif    if (CheckForUserInput() > 0)    {      /* Stop recorder and exit the test (go to next test) */      BSP_AUDIO_IN_Stop();      return;    }  }  /* Stop recorder once buffer_ctl.rec_length < AUDIO_REC_TOTAL_SIZE*/  BSP_AUDIO_IN_Stop();  BSP_LCD_SetBackColor(LCD_COLOR_WHITE);  BSP_LCD_SetTextColor(LCD_COLOR_BLUE);  sprintf((char*)FreqStr, "RECORDING DONE, %d frames, START PLAYBACK", NbRecord_done);  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 65, (uint8_t *)FreqStr, CENTER_MODE);  NbRecord_done = buffer_ctl.rec_length / (DEFAULT_AUDIO_IN_FREQ * DEFAULT_AUDIO_IN_CHANNEL_NBR * 2);  sprintf((char*)FreqStr, "Elapsed_time: %d frames", NbRecord_done);  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 45, (uint8_t *)FreqStr, CENTER_MODE);  /* -----------Start Playback -------------- */  /* Initialize audio IN at REC_FREQ*/  if(BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_HEADPHONE, 95, DEFAULT_AUDIO_IN_FREQ/2) == 0)  {    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);    BSP_LCD_SetTextColor(LCD_COLOR_GREEN);    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 95, (uint8_t *)"  AUDIO CODEC   OK  ", CENTER_MODE);  }  else  {    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);    BSP_LCD_SetTextColor(LCD_COLOR_RED);    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 95, (uint8_t *)"  AUDIO CODEC  FAIL ", CENTER_MODE);    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 80, (uint8_t *)" Try to reset board ", CENTER_MODE);  }  /* Play the recorded buffer*/  if(AUDIO_Play_Start((uint32_t *)AUDIO_REC_START_ADDR, (uint32_t)AUDIO_REC_TOTAL_SIZE) == 0)  {    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);    BSP_LCD_SetTextColor(LCD_COLOR_GREEN);    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 95, (uint8_t *)"  AUDIO PLAYBACK   OK  ", CENTER_MODE);  } else  {    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);    BSP_LCD_SetTextColor(LCD_COLOR_RED);    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 95, (uint8_t *)"  AUDIO PLAYBACK  FAIL ", CENTER_MODE);  }    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 25, (uint8_t *)"PLAYBACK DONE", CENTER_MODE);  while (1)  {    /* Toggle LED4 */    BSP_LED_Toggle(LED4);    /* Insert 100 ms delay */    HAL_Delay(100);    if (CheckForUserInput() > 0)    {      /* Set LED4 */      BSP_LED_On(LED4);      /* Stop recorder */      BSP_AUDIO_IN_Stop();      /* Stop Player before close Test */      BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);      return;    }  }}
开发者ID:Lembed,项目名称:STM32CubeF4-mirrors,代码行数:101,


示例25: HAL_I2C_MasterTxCpltCallback

void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *I2cHandle){  /* Toggle LED2: Transfer in transmission process is correct */  BSP_LED_Toggle(LED2);}
开发者ID:jmoyerman,项目名称:stm32f0_cube,代码行数:5,


示例26: main

//.........这里部分代码省略.........  __HAL_UART_ENABLE_IT(&UartHandle, UART_IT_WUF);    /* about to enter stop mode: switch off LED */  BSP_LED_Off(LED3);  /* enable MCU wake-up by UART */  HAL_UARTEx_EnableStopMode(&UartHandle);   /* enter stop mode */  HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);  /* ... STOP mode ... */    SystemClock_Config_fromSTOP();  /* at that point, MCU has been awoken: the LED has been turned back on */  /* Wake Up on 4-bit address detection successful */   /* wait for some delay */  HAL_Delay(100);  /* Inform other board that wake up is successful */  if (HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer4, COUNTOF(aTxBuffer4)-1, 5000)!= HAL_OK)    {    Error_Handler();  }   #else/* initialize the User push-button in Interrupt mode */  BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);    /* Wait for User push-button press before starting the test.     In the meantime, LED3 is blinking */  while(UserButtonStatus == 0)  {      /* Toggle LED3 */      BSP_LED_Toggle(LED3);       HAL_Delay(100);  }      /*##-2- Send the wake-up from stop mode first trigger ######################*/  /*      (RXNE flag setting)                                                 */  BSP_LED_On(LED3);  if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aWakeUpTrigger1, COUNTOF(aWakeUpTrigger1)-1, 5000)!= HAL_OK)  {    Error_Handler();  }    /* Put UART peripheral in reception process to wait for other board     wake up confirmation */    if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, COUNTOF(aTxBuffer1)-1, 10000) != HAL_OK)  {    Error_Handler();  }   BSP_LED_Off(LED3);     /* Compare the expected and received buffers */  if(Buffercmp((uint8_t*)aTxBuffer1,(uint8_t*)aRxBuffer,COUNTOF(aTxBuffer1)-1))  {    Error_Handler();  }   /* wait for two seconds before test second step */  HAL_Delay(2000);    /*##-3- Send the wake-up from stop mode second trigger #####################*/  /*      (start Bit detection)                                               */
开发者ID:jmoyerman,项目名称:stm32f0_cube,代码行数:67,


示例27: 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:nidhiyanandh,项目名称:STM32Cube_FW_F4_V1.5.0_GCC_Makefile,代码行数:94,


示例28: HAL_TIM_PeriodElapsedCallback

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){  BSP_LED_Toggle(LED_GREEN);  return;}
开发者ID:ptracton,项目名称:STM32,代码行数:4,



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


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