本文整理汇总了C++中HAL_GPIO_TogglePin函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_GPIO_TogglePin函数的具体用法?C++ HAL_GPIO_TogglePin怎么用?C++ HAL_GPIO_TogglePin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HAL_GPIO_TogglePin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
int i;
HAL_Init();
SystemClock_Config();
__GPIOC_CLK_ENABLE();
// LEDs on Discovery F0
GPIO_InitTypeDef GPIO_InitTypeDefStruct;
GPIO_InitTypeDefStruct.Pin = GPIO_PIN_9 | GPIO_PIN_8;
GPIO_InitTypeDefStruct.Mode= GPIO_MODE_OUTPUT_PP;
GPIO_InitTypeDef* GPIO_Init= & GPIO_InitTypeDefStruct;
HAL_GPIO_Init(GPIOC,GPIO_Init);
while (1) {
for (i = 1000000; i > 0; i--);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_9);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_8);
}
/* Infinite loop */
exit (1);
}
示例2: send
void send(uint8_t status, uint8_t* buffer, uint8_t buffer_length) {
uint8_t transmitBuffer[UART_command_length + 1];
transmitBuffer[0] = MORE_DATA;
uint8_t total_transmitted = 0;
while (total_transmitted < buffer_length) {
if (buffer_length - total_transmitted <= UART_command_length) {
transmitBuffer[0] = status;
}
for (int i = 0; i < UART_command_length; i++) {
if (total_transmitted < buffer_length) {
transmitBuffer[i+1] = buffer[total_transmitted];
} else {
transmitBuffer[i+1] = 0;
}
total_transmitted++;
}
if (HAL_UART_Transmit(&hUART, (unsigned char*) transmitBuffer, UART_command_length + 1, 1000) != HAL_OK) {
Output_High(FAIL_LED_GPIOx, FAIL_LED_Pin);
Output_High(BUSY_LED_GPIOx, BUSY_LED_Pin);
for (int i = 0; i < 10; i++) {
HAL_GPIO_TogglePin(FAIL_LED_GPIOx, FAIL_LED_Pin);
HAL_GPIO_TogglePin(BUSY_LED_GPIOx, BUSY_LED_Pin);
HAL_Delay(50);
}
}
HAL_Delay(100);
}
}
示例3: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* This sample code shows how to use GPIO HAL API to toggle LED1, LED2, LED3 and LED4 IOs
in an infinite loop. */
/* 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 the system clock to 72 MHz */
SystemClock_Config();
/* -1- Enable each GPIO Clock (to be able to program the configuration registers) */
LED1_GPIO_CLK_ENABLE();
LED2_GPIO_CLK_ENABLE();
LED3_GPIO_CLK_ENABLE();
LED4_GPIO_CLK_ENABLE();
/* -2- Configure IOs in output push-pull mode to drive external LEDs */
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pin = LED1_PIN;
HAL_GPIO_Init(LED1_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LED2_PIN;
HAL_GPIO_Init(LED2_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LED3_PIN;
HAL_GPIO_Init(LED3_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LED4_PIN;
HAL_GPIO_Init(LED4_GPIO_PORT, &GPIO_InitStruct);
/* -3- Toggle IOs in an infinite loop */
while (1)
{
HAL_GPIO_TogglePin(LED1_GPIO_PORT, LED1_PIN);
/* Insert delay 100 ms */
HAL_Delay(100);
HAL_GPIO_TogglePin(LED2_GPIO_PORT, LED2_PIN);
/* Insert delay 100 ms */
HAL_Delay(100);
HAL_GPIO_TogglePin(LED3_GPIO_PORT, LED3_PIN);
/* Insert delay 100 ms */
HAL_Delay(100);
HAL_GPIO_TogglePin(LED4_GPIO_PORT, LED4_PIN);
/* Insert delay 100 ms */
HAL_Delay(100);
}
}
示例4: main
int main(void)
{
uint32_t bootStatus;
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
/* Turn on led Init */
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_12|GPIO_PIN_13, GPIO_PIN_RESET);
/* Wait for timeout */
bootStatus = bootWait(5000);
/* Turn off led */
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_12|GPIO_PIN_13, GPIO_PIN_SET);
/* Check for Result */
if(bootStatus == 0)
{
/* Test if user code is programmed starting from address USBD_DFU_APP_DEFAULT_ADD */
if(((*(__IO uint32_t*)USBD_DFU_APP_DEFAULT_ADD) & 0x2FFE0000 ) == 0x20000000)
{
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (USBD_DFU_APP_DEFAULT_ADD + 4);
JumpToApplication = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) USBD_DFU_APP_DEFAULT_ADD);
JumpToApplication();
}
/* load application failed */
while (1)
{
HAL_Delay(50);
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_12|GPIO_PIN_13);
}
}
/* Init Device Library,Add Supported Class and Start the library*/
USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS);
USBD_RegisterClass(&hUsbDeviceFS, &USBD_DFU);
USBD_DFU_RegisterMedia(&hUsbDeviceFS, &USBD_DFU_fops_FS);
USBD_Start(&hUsbDeviceFS);
/* Infinite loop */
while (1)
{
HAL_Delay(500);
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_13);
}
}
示例5: main
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_2);
HAL_Delay(100);
HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_8);
HAL_Delay(100);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
示例6: can2RxCpltCallback
/**
* @brief Rx Transfer completed callback
* @param None
* @retval None
*/
void can2RxCpltCallback()
{
// if ((CAN_Handle.pRxMsg->StdId == 0x321) && (CAN_Handle.pRxMsg->IDE == CAN_ID_STD) && (CAN_Handle.pRxMsg->DLC == 2))
// {
// HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_3);
// volatile uint8_t test1 = CAN_Handle.pRxMsg->Data[0];
// volatile uint8_t test2 = CAN_Handle.pRxMsg->Data[1];
// }
if (prvRxBuffer1State != CANBufferState_Reading && prvRxBuffer1Count < RX_BUFFER_SIZE)
{
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_3);
prvRxBuffer1State = CANBufferState_Writing;
/* Save the message */
prvRxBuffer1[prvRxBuffer1CurrentIndex].id = CAN_Handle.pRxMsg->StdId;
prvRxBuffer1[prvRxBuffer1CurrentIndex].dlc = CAN_Handle.pRxMsg->DLC;
for (uint32_t i = 0; i < CAN_Handle.pRxMsg->DLC; i++)
prvRxBuffer1[prvRxBuffer1CurrentIndex].data[i] = CAN_Handle.pRxMsg->Data[i];
/* Increment the counters */
prvRxBuffer1CurrentIndex++;
prvRxBuffer1Count++;
/* Start the timer which will clear the buffer if it's not already started */
if (xTimerIsTimerActive(prvBuffer1ClearTimer) == pdFALSE)
xTimerStartFromISR(prvBuffer1ClearTimer, NULL);
}
else if (prvRxBuffer2State != CANBufferState_Reading && prvRxBuffer2Count < RX_BUFFER_SIZE)
{
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_3);
prvRxBuffer2State = CANBufferState_Writing;
/* Save the message */
prvRxBuffer2[prvRxBuffer1CurrentIndex].id = CAN_Handle.pRxMsg->StdId;
prvRxBuffer2[prvRxBuffer1CurrentIndex].dlc = CAN_Handle.pRxMsg->DLC;
for (uint32_t i = 0; i < CAN_Handle.pRxMsg->DLC; i++)
prvRxBuffer2[prvRxBuffer1CurrentIndex].data[i] = CAN_Handle.pRxMsg->Data[i];
/* Increment the counters */
prvRxBuffer2CurrentIndex++;
prvRxBuffer2Count++;
/* Start the timer which will clear the buffer if it's not already started */
if (xTimerIsTimerActive(prvBuffer2ClearTimer) == pdFALSE)
xTimerStartFromISR(prvBuffer2ClearTimer, NULL);
}
else
{
/* No buffer available, something has gone wrong */
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_3);
}
/* Receive */
if (HAL_CAN_Receive_IT(&CAN_Handle, CAN_FIFO1) != HAL_OK)
{
/* Reception Error */
// Error_Handler();
}
}
示例7: HAL_ADC_ConvCpltCallback
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* AdcHandle)
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_9);
HAL_ADC_Stop_DMA(&g_AdcHandle);
osSignalSet(tid_TH_GUI,DMA_ConvCpltSig);
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_9);
//GPIOB->ODR ^= GPIO_PIN_9; // this is just for test of DMA speed
}
示例8: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32F2xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Global MSP (MCU Support Package) initialization
*/
HAL_Init();
/* Configure the system clock to 120 MHz */
SystemClock_Config();
/* -1- Enable GPIOG, GPIOC and GPIOI Clock (to be able to program the configuration registers) */
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOI_CLK_ENABLE();
/* -2- Configure PG.6, PG.8, PI.9 and PC.7 IOs in output push-pull mode to
drive external LEDs */
GPIO_InitStruct.Pin = (GPIO_PIN_6 | GPIO_PIN_8);
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* -3- Toggle PG.6, PG.8, PI.9 and PC.7 IOs in an infinite loop */
while (1)
{
HAL_GPIO_TogglePin(GPIOG, GPIO_PIN_6);
/* Insert delay 100 ms */
HAL_Delay(100);
HAL_GPIO_TogglePin(GPIOG, GPIO_PIN_8);
/* Insert delay 100 ms */
HAL_Delay(100);
HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_9);
/* Insert delay 100 ms */
HAL_Delay(100);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_7);
/* Insert delay 100 ms */
HAL_Delay(100);
}
}
示例9: main
int main(void)
{
/* USER CODE BEGIN 1 */
char ADC_Tx_Data[70];
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
HAL_UART_Receive_IT(&huart1, (uint8_t *)Rx_Data, 1);
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)&ADC_Value, 6);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_Delay(15);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_4);
HAL_Delay(15);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_0);
HAL_Delay(15);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_1);
HAL_Delay(15);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_2);
HAL_Delay(15);
sprintf(ADC_Tx_Data,"ADC1:%4d\tADC2:%4d\tADC3:%4d\tADC4:%4d\tADC5:%4d\tADC6:%4d\n\r", ADC_Value[0], ADC_Value[1], ADC_Value[2], ADC_Value[3], ADC_Value[4], ADC_Value[5]);
HAL_UART_Transmit_IT(&huart1, (uint8_t *)ADC_Tx_Data, 70);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
示例10: main
int main(void) {
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_USART3_UART_Init();
MX_TIM2_Init();
/* USER CODE BEGIN 2 */
nec.timerHandle = &htim2;
nec.timerChannel = TIM_CHANNEL_1;
nec.timerChannelActive = HAL_TIM_ACTIVE_CHANNEL_1;
nec.timingBitBoundary = 1680;
nec.timingAgcBoundary = 12500;
nec.type = NEC_NOT_EXTENDED;
nec.NEC_DecodedCallback = myNecDecodedCallback;
nec.NEC_ErrorCallback = myNecErrorCallback;
nec.NEC_RepeatCallback = myNecRepeatCallback;
NEC_Read(&nec);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_12);
HAL_Delay(100);
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_13);
HAL_Delay(100);
}
/* USER CODE END 3 */
}
示例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 the system clock to 100 MHz */
SystemClock_Config();
/*##-1- Enable GPIOA Clock (to be able to program the configuration registers) */
__HAL_RCC_GPIOA_CLK_ENABLE();
/*##-2- Configure PA05 IO in output push-pull mode to drive external LED ###*/
GPIO_InitStruct.Pin = GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*##-3- Toggle PA05 IO in an infinite loop #################################*/
while (1)
{
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
/* Insert a 100ms delay */
HAL_Delay(100);
}
}
示例12: LED_Thread1
static void LED_Thread1(void const *argument)
{
GPIO_InitTypeDef GPIO_InitStruct_LED, GPIO_InitStruct_BUTTON;
/* GPIO Ports Clock Enable */
__GPIOI_CLK_ENABLE();
/*Configure GPIO pin : PI1 */
GPIO_InitStruct_LED.Pin = GPIO_PIN_1;
GPIO_InitStruct_LED.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct_LED.Pull = GPIO_NOPULL;
GPIO_InitStruct_LED.Speed = GPIO_SPEED_LOW;
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct_LED);
GPIO_InitStruct_BUTTON.Pin = GPIO_PIN_11;
GPIO_InitStruct_BUTTON.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct_BUTTON.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct_BUTTON);
while(1)
{
if(HAL_GPIO_ReadPin(GPIOI, GPIO_PIN_11)){
HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_1);
HAL_Delay(500);
printf("Pintando \n");
}
HAL_GPIO_WritePin(GPIOI, GPIO_PIN_1, 0);
}
}
示例13: myNecRepeatCallback
void myNecRepeatCallback() {
char* msg = "Repeat!\n";
HAL_UART_Transmit_DMA(&huart3, (uint8_t*) msg, strlen(msg));
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_15);
HAL_Delay(10);
NEC_Read(&nec);
}
示例14: rs232RxCpltCallback
/**
* @brief Rx Transfer completed callback
* @param None
* @retval None
*/
void rs232RxCpltCallback()
{
if (prvRxBuffer1State != BUFFERState_Reading && prvRxBuffer1Count < RX_BUFFER_SIZE)
{
prvRxBuffer1State = BUFFERState_Writing;
prvRxBuffer1[prvRxBuffer1CurrentIndex++] = prvReceivedByte;
prvRxBuffer1Count++;
/* Start the timer which will clear the buffer if it's not already started */
if (xTimerIsTimerActive(prvBuffer1ClearTimer) == pdFALSE)
xTimerStartFromISR(prvBuffer1ClearTimer, NULL);
}
else if (prvRxBuffer2State != BUFFERState_Reading && prvRxBuffer2Count < RX_BUFFER_SIZE)
{
prvRxBuffer2State = BUFFERState_Writing;
prvRxBuffer2[prvRxBuffer2CurrentIndex++] = prvReceivedByte;
prvRxBuffer2Count++;
/* Start the timer which will clear the buffer if it's not already started */
if (xTimerIsTimerActive(prvBuffer2ClearTimer) == pdFALSE)
xTimerStartFromISR(prvBuffer2ClearTimer, NULL);
}
else
{
/* No buffer available, something has gone wrong */
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_3);
}
/* Continue receiving data */
HAL_UART_Receive_IT(&UART_Handle, &prvReceivedByte, 1);
/* Give back the semaphore now that we are done */
xSemaphoreGiveFromISR(xSemaphore, NULL);
}
示例15: main
int main(void)
{
HAL_Init();
led_gpio_init();
SystemClock_Config();
mima_init();
usbKB_init();
USBD_Init(&USBD_Device, &HID_Desc, 0);
USBD_RegisterClass(&USBD_Device, USBD_HID_CLASS);
USBD_CUSTOM_HID_RegisterInterface(&USBD_Device, &USBD_CustomHID_fops);
USBD_Start(&USBD_Device);
HAL_Delay(1000);
USB_KB_type("Hello world", 11);
while(1) {
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7);
mima_loop();
}
}