本文整理汇总了C++中GPIO_ToggleBits函数的典型用法代码示例。如果您正苦于以下问题:C++ GPIO_ToggleBits函数的具体用法?C++ GPIO_ToggleBits怎么用?C++ GPIO_ToggleBits使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GPIO_ToggleBits函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NEC_ReceiveInterrupt
void NEC_ReceiveInterrupt(NEC_FRAME f) {
GPIO_ToggleBits(GPIOD, GPIO_Pin_7);
char buf[12];
USART_WriteString("NEC Frame was received : \r\nAddress : ");
Int2Str(buf, f.Address);
USART_WriteString(buf);
USART_WriteString("\r\nCommand : ");
Int2Str(buf, f.Command);
USART_WriteString(buf);
USART_WriteString("\r\n");
switch (f.Command) {
case 1:
GPIO_ToggleBits(GPIOD, GPIO_Pin_12);
break;
case 2:
GPIO_ToggleBits(GPIOD, GPIO_Pin_13);
break;
case 3:
GPIO_ToggleBits(GPIOD, GPIO_Pin_14);
break;
case 4:
GPIO_ToggleBits(GPIOD, GPIO_Pin_15);
break;
}
}
示例2: main
int main(void) {
///////// Initial Portion /////////////////////////
init_USART1(9600); // initialize USART1 @ 9600 baud
SystemCoreClockUpdate(); /* Get Core Clock Frequency */
if (SysTick_Config(SystemCoreClock / 1000)) { /* SysTick 1 msec interrupts */
while (1); /* Capture error */
}
USART_puts(USART1, "Init 1 complete! Hello World!rn"); // just send a message to indicate that it works
//Init GPIO for Leds on board and button input
init_GPIO();
/////////////////- Loop - ////////////////////////////////////
while (1){
// You can do whatever you want in here
USART_puts(USART1, "Init 2 complete! Hello World! \r \n"); // just send a message to indicate that it works
//GPIO_ToggleBits(GPIOD, GPIO_Pin_15 | GPIO_Pin_14 | GPIO_Pin_13| GPIO_Pin_12 );
GPIO_ToggleBits(GPIOD, GPIO_Pin_12 ); //Test Leds on board
Delay(200);
GPIO_ToggleBits(GPIOD, GPIO_Pin_13 ); //Test Leds on board
Delay(200);
GPIO_ToggleBits(GPIOD, GPIO_Pin_14 ); //Test Leds on board
Delay(1000);
}
//////////////////////////////////////////////////////////
}
示例3: gpio_toggle
/*******************************************************************************
* Function Name : gpio_toggle
* Description : Toggle the value of a specified GPIO
* Input : - Gpio: Select the GPIO to be toggled
* Output : None
* Return : None
*******************************************************************************/
void gpio_toggle(const _Gpio_Descriptor *Gpio)
{
if (!Gpio) return;
#ifdef _GPIO_I2CIO_SUPPORT
if (gpio_is_i2c(Gpio)) i2cio_toggle_output(Gpio->Port, Gpio->GPIO_Pin);
else GPIO_ToggleBits((GPIO_TypeDef *)Gpio->Port, Gpio->GPIO_Pin);
#else
GPIO_ToggleBits((GPIO_TypeDef *)Gpio->Port, Gpio->GPIO_Pin);
#endif
}
示例4: TIMER32_0_IRQHandler
void TIMER32_0_IRQHandler()
{
static unsigned int duty_counter_r = 0;
static unsigned int duty_counter_g = 0;
static unsigned int duty_counter_b = 0;
static unsigned int bl_duty_counter = 0;
static unsigned int period_counter = 0;
static int activity_counter = 0;
CoEnterISR();
TIM_ClearIntPending(LPC_TMR32B0, TIM_MR0_INT);
// 39.0625us activity indicator (for calibration)
GPIO_ToggleBits(TIMER_ACTIVITY_PORT, TIMER_ACTIVITY_PIN);
if( period_counter -- > 0 ) {
if( duty_counter_r -- == 0 )
GPIO_ResetBits(RED_PORT, RED_PIN);
if( duty_counter_g -- == 0 )
GPIO_ResetBits(GREEN_PORT, GREEN_PIN);
if( duty_counter_b -- == 0 )
GPIO_ResetBits(BLUE_PORT, BLUE_PIN);
if (bl_duty_counter-- == 0)
GPIO_ResetBits(LCD_BACKLITE_PORT, LCD_BACKLITE_PIN);
}
else {
if( activity_counter ++ >= TICKS_PER_SECOND ) {
activity_counter = 0;
GPIO_ToggleBits(TIMER_ACTIVITY_PORT, TIMER_ACTIVITY_PIN);
//if( device_mode == AMBIENT_TEMPERATURE )
// PLUGIN_Temperature_Update();
}
SEQ_Tick();
duty_counter_r = SEQ_CurrentRed();
duty_counter_r == 0 ? GPIO_ResetBits(RED_PORT, RED_PIN) : GPIO_SetBits(RED_PORT, RED_PIN);
duty_counter_g = SEQ_CurrentGreen();
duty_counter_g == 0 ? GPIO_ResetBits(GREEN_PORT, GREEN_PIN ) : GPIO_SetBits(GREEN_PORT, GREEN_PIN );
duty_counter_b = SEQ_CurrentBlue();
duty_counter_b == 0 ? GPIO_ResetBits(BLUE_PORT, BLUE_PIN ) : GPIO_SetBits(BLUE_PORT, BLUE_PIN );
bl_duty_counter = backlite_power;
bl_duty_counter == 0 ? GPIO_ResetBits(LCD_BACKLITE_PORT, LCD_BACKLITE_PIN) : GPIO_SetBits(LCD_BACKLITE_PORT, LCD_BACKLITE_PIN);
period_counter = 255;
}
CoExitISR();
}
示例5: main
int main(void) {
uint8_t c;
/* System Init */
SystemInit();
/* Initialize LED's. Make sure to check settings for your board in tm_stm32f4_disco.h file */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE); //
GPIO_InitTypeDef GPIO_InitDef;
GPIO_InitDef.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14; // we gaan pin 13 en 14 gebruiken
GPIO_InitDef.GPIO_OType = GPIO_OType_PP; // init push-pull
GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // init output
GPIO_InitDef.GPIO_PuPd = GPIO_PuPd_NOPULL; // init no pullup
GPIO_InitDef.GPIO_Speed = GPIO_Speed_100MHz; // init 100 MHZ
//Initialize pins
GPIO_Init(GPIOG, &GPIO_InitDef);
GPIO_ToggleBits(GPIOG, GPIO_Pin_13);
/* Initialize USB VCP */
TM_USB_VCP_Init();
while (1) {
/* USB configured OK, drivers OK */
if (TM_USB_VCP_GetStatus() == TM_USB_VCP_CONNECTED) {
/* Turn on GREEN led */
//TM_DISCO_LedOn(LED_GREEN);
//TM_DISCO_LedOff(LED_RED);
/* If something arrived at VCP */
if (TM_USB_VCP_Getc(&c) == TM_USB_VCP_DATA_OK) {
/* Return data back */
TM_USB_VCP_Putc('0' + (c /100) % 10);
TM_USB_VCP_Putc('0' + (c /10) % 10);
TM_USB_VCP_Putc('0' + c % 10);
TM_USB_VCP_Putc(',');
TM_USB_VCP_Putc(' ');
GPIO_ToggleBits(GPIOG, GPIO_Pin_13 | GPIO_Pin_14);
}
else
{
//TM_USB_VCP_Putc(' ');
}
} else {
/* USB not OK */
//TM_DISCO_LedOff(LED_GREEN);
//TM_DISCO_LedOn(LED_RED);
}
}
}
示例6: flipBuffers
void flipBuffers()
{
char *tempBuffer = currentReadBuffer;
currentReadBuffer = currentWriteBuffer;
currentWriteBuffer = tempBuffer;
read_ptr = currentReadBuffer;
rxIndex = 0;
countFlips += 1;
GPIO_ToggleBits(GPIOD, GPIO_Pin_11);
GPIO_ToggleBits(GPIOD, GPIO_Pin_11);
}
示例7: blinkDebugLeds
//Rotina para exibir, visualmente, que os dispostivios foram iniciados
void blinkDebugLeds() {
GPIO_ToggleBits(GPIOD, GPIO_Pin_12);
delay(2500);
GPIO_ToggleBits(GPIOD, GPIO_Pin_12);
delay(2500);
GPIO_ToggleBits(GPIOD, GPIO_Pin_13);
delay(2500);
GPIO_ToggleBits(GPIOD, GPIO_Pin_13);
delay(2500);
GPIO_ToggleBits(GPIOD, GPIO_Pin_14);
delay(2500);
GPIO_ToggleBits(GPIOD, GPIO_Pin_14);
delay(2500);
GPIO_ToggleBits(GPIOD, GPIO_Pin_15);
delay(2500);
GPIO_ToggleBits(GPIOD, GPIO_Pin_15);
delay(2500);
}
示例8: LogA_ToggleActiveLED
void LogA_ToggleActiveLED(void)
{
switch (LEDCurrentlyBlinking)
{
case LEDBlinking_Red_Slowly :
case LEDBlinking_Red_Quickly :
{
GPIO_ToggleBits(LEDRED);
GPIO_ResetBits(LEDORANGE);
GPIO_ResetBits(LEDGREEN);
GPIO_ResetBits(LEDBLUE);
}
break;
case LEDBlinking_Orange_Slowly :
case LEDBlinking_Orange_Quickly :
{
GPIO_ResetBits(LEDRED);
GPIO_ToggleBits(LEDORANGE);
GPIO_ResetBits(LEDGREEN);
GPIO_ResetBits(LEDBLUE);
}
break;
case LEDBlinking_Green_Slowly :
case LEDBlinking_Green_Quickly :
{
GPIO_ResetBits(LEDRED);
GPIO_ResetBits(LEDORANGE);
GPIO_ToggleBits(LEDGREEN);
GPIO_ResetBits(LEDBLUE);
}
break;
case LEDBlinking_Blue_Slowly :
case LEDBlinking_Blue_Quickly :
{
GPIO_ResetBits(LEDRED);
GPIO_ResetBits(LEDORANGE);
GPIO_ResetBits(LEDGREEN);
GPIO_ToggleBits(LEDBLUE);
}
break;
case LEDBlinking_ToggleAllFour :
{
GPIO_ToggleBits(LEDRED);
GPIO_ToggleBits(LEDORANGE);
GPIO_ToggleBits(LEDGREEN);
GPIO_ToggleBits(LEDBLUE);
}
break;
// Covers LEDBlinking_None
default:
{
GPIO_ResetBits(LEDRED);
GPIO_ResetBits(LEDORANGE);
GPIO_ResetBits(LEDGREEN);
GPIO_ResetBits(LEDBLUE);
}
break;
}
}
示例9: RxPacket
void RxPacket(void const *argument){
uint8_t mode_filter, transmit_mode;
//uint8_t buf;
uint8_t buf;
Packet pkt;
GPIO_ResetBits(GPIOD, GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);
mode_filter = 0x70;
transmit_mode = 0x20;
printf("Thread_started. waitig for signal\n");
// put reciever in RX mode
CC2500_Strobe(CC2500_STROBE_SRX, 0x00);
while(1){
int i;
osSignalWait(RX_PKT, osWaitForever);
//turn on LED on packet RX
GPIO_ToggleBits(GPIOD, GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);
CC2500_Read(&buf ,CC2500_FIFO_ADDR, 1);
//CC2500_RxPackets((uint8_t*)&pkt, CC2500_SETTING_PKTLEN + 2);
printf("buf is %d \n", buf);
if(pkt.Src_addr == 0x01){
i++;
// put the measured RSSI in byte 3 for main board
pkt.Aux_rssi = pkt.Rssi;
printf("%d Packet received from user beacon\n", i);
printf("SRC: 0x%02x\t\t", pkt.Src_addr);
printf("SEQ: 0x%02x\t\t", pkt.Seq_num);
printf("RAW_RSSI: 0x%02x\n", pkt.Rssi);
buf = CC2500_Strobe(CC2500_STROBE_SRX, 0x3F);
printf("Buffer : 0x%02x\n", buf);
}
// change the source address on the packet
pkt.Src_addr = CC2500_SETTING_ADDR;
// transmit this packet for main board
osDelay(100);
CC2500_TxPacket((uint8_t*)&pkt, CC2500_SETTING_PKTLEN);
// turn off LED on successful Tx
GPIO_ToggleBits(GPIOD, GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);
// put device back to rx mode
osDelay(100);
}
}
示例10: USART3_IRQHandler
// this is the interrupt request handler (IRQ) for ALL USART3 interrupts
void USART3_IRQHandler(void){
// check if the USART3 receive interrupt flag was set
if( USART_GetITStatus(USART3, USART_IT_RXNE) ){
/*check the uart RX have accept the char*/
GPIO_ToggleBits(GPIOD,GPIO_Pin_14);
static uint8_t cnt = 0; // this counter is used to determine the uart receive string length
//Receive_data = USART3->DR; // the character from the USART3 data register is saved in t
Receive_data = USART_ReceiveData(USART3);;
/* check if the received character is not the LF character (used to determine end of string)
* or the if the maximum string length has been been reached
*/
if( cnt < MAX_STRLEN){
received_string[cnt] = Receive_data;
if(Receive_data=='0') GPIO_ToggleBits(GPIOD,GPIO_Pin_15);
/*start determine the period of command.*/
if(received_string[cnt]=='\r'){
Receive_String_Ready = 1; /*Ready to parse the command */
cnt=0; /*restart to accept next stream message.*/
}
else{
cnt++;
}
}
else{ // over the max string length, cnt return to zero.
Receive_String_Ready=1;
cnt = 0;
}
if(Receive_String_Ready){
//print the content of the received string
USART_puts(USART3, received_string);
USART_puts(USART3,"\r\n");
//receive_task();
/*clear the received string and the flag*/
Receive_String_Ready = 0;
int i;
for( i = 0 ; i< MAX_STRLEN ; i++){
received_string[i]= 0;
}
}
}
}
示例11: tcp_rx_handler
void tcp_rx_handler(void)
{
if(crc32((uint8_t*)&rx_tcp_msg+4,rx_tcp_msg.msg_len + TCP_HEADER_SIZE - 4) == rx_tcp_msg.msg_crc)
{
switch(rx_tcp_msg.msg_id)
{
case CHECK_CONNECT:
tcp_write(pout_pcb," соединение установлено",23,1);
tcp_output(pout_pcb);
tcp_sent(pout_pcb,NULL);
break;
case SEND_FILE:
{
int adr = rx_tcp_msg.data[0];
int size = rx_tcp_msg.msg_len - 1;
memcpy(&buffer[adr][0],&rx_tcp_msg.data[1],size);
}
break;
case SET_DATA_DAC:
{
unsigned short data_temp = *((unsigned short*)&rx_tcp_msg.data[0]);
for (int i = 0; i < 8192; i++) *(uint16_t *) (sram_bank4 + 0) = data_temp;
GPIO_ToggleBits(GPIOI, GPIO_Pin_0);
}
break;
case SEND_FILE_DONE:
{
int adr,size;
unsigned short *pbuffer = (unsigned short*)&buffer[0][0];
adr = rx_tcp_msg.data[0];
size = rx_tcp_msg.msg_len - 1;
memcpy(&buffer[adr][0],&rx_tcp_msg.data[1],size);
for (int i = 0; i < 8192; i++) *(uint16_t *) (sram_bank4 + 0) = *(pbuffer++);
GPIO_ToggleBits(GPIOI, GPIO_Pin_0);
}
break;
}
}
}
示例12: main
int main(void)
{
Timer_init();
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 |GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD, &GPIO_InitStructure);
static uint32_t timerValue;
uint32_t lastTime = TIM2->CNT;
while (1)
{
timerValue = TIM2->CNT;
if( timerValue - lastTime > 1000000 )
{
GPIO_ToggleBits(GPIOD, GPIO_Pin_12 |GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);
lastTime = timerValue;
}
}
}
示例13: main
int main(void)
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
/* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD, &GPIO_InitStructure);
uint8_t rec;
spi_init();
while (1)
{
GPIO_ToggleBits( GPIOD, GPIO_Pin_15 );
GPIOC->BSRRH |= GPIO_Pin_4;
rec = spi_send( 0xaa );
GPIOC->BSRRL |= GPIO_Pin_4;
Delay( 0xffff );
}
}
示例14: main
int main(void)
{
uint8_t colorR =0 ,colorG =0 ,colorB =0 ;
uint8_t colorR_dir =0 ,colorG_dir =0 ,colorB_dir =0 ;
char lcd_text_buff[100];
float GyX =0.0f, GyY =0.0f, GyZ =0.0f;
float X_offset =0.0f,Y_offset =0.0f,Z_offset =0.0f;
uint32_t i=0;
float delay_count=1000.0f;
GPIO_Configuration();
USART1_Configuration();
CANx_Config();
CANx_NVIC_Config();
lcd_init();
lcd_drawBackground(20,60,250);
lcd_drawBGPersimmon(20, 60, 250);
LCD_SetColors(LCD_COLOR_WHITE-1,LCD_COLOR_WHITE);
LCD_SetFont(&Font16x24);
LCD_DisplayStringLine(LINE(1), (uint8_t*)" CAN Bus DEMO ");
DrawNeedle(120,120,60,300.0f,0.0f,200.0f);
while (1)
{
CANx_Transmit();
GPIO_ToggleBits(LED4);
Delay_1us(1000);
}
}
示例15: vLEDTask
void vLEDTask( void *pvParameters ) {
const portTickType xDelay = 1000;
while(1) {
GPIO_ToggleBits(GPIOD, GPIO_Pin_12);
vTaskDelay(xDelay);
}
}