コード例 #1
0
/**************************************************************************//**
 * @brief
 *   Start a USB bulk-in transfer to send a CSW back to host.
 *****************************************************************************/
__STATIC_INLINE void SendCsw(void)
{
  if ( ledPort != -1 )
    GPIO_PinOutToggle((GPIO_Port_TypeDef)ledPort, ledPin);

  USBD_Write(BULK_IN, (void*) &csw, CSW_LEN, NULL);
}
コード例 #2
0
__LINK_C error_t hw_gpio_toggle(pin_id_t pin_id)
{
    if(!(gpio_pins_configured[pin_id.port] & (1<<pin_id.pin)))
	return EOFF;
    GPIO_PinOutToggle(pin_id.port, pin_id.pin);
    return SUCCESS;
}
コード例 #3
0
ファイル: displaypalemlib.c プロジェクト: JamesH001/SX1231
/***************************************************************************//**
 * @brief
 *   Toggle a single pin in GPIO port data out register.
 *
 * @note
 *   In order for the setting to take effect on the output pad, the pin must
 *   have been configured properly. If not, it will take effect whenever the
 *   pin has been properly configured.
 *
 * @param[in] port
 *   The GPIO port to access.
 *
 * @param[in] pin
 *   The pin to toggle.
 ******************************************************************************/
EMSTATUS PAL_GpioPinOutToggle(unsigned int port, unsigned int pin)
{
  EMSTATUS status = PAL_EMSTATUS_OK;

  GPIO_PinOutToggle((GPIO_Port_TypeDef) port, pin);

  return status;
}
コード例 #4
0
ファイル: bsp_stk_leds.c プロジェクト: peterliu2/FreeRTOS
int BSP_LedToggle(int ledNo)
{
    if ((ledNo >= 0) && (ledNo < BSP_NO_OF_LEDS)) {
        GPIO_PinOutToggle(ledArray[ledNo].port, ledArray[ledNo].pin);
        return BSP_STATUS_OK;
    }
    return BSP_STATUS_ILLEGAL_PARAM;
}
コード例 #5
0
ファイル: displaypalemlib.c プロジェクト: JamesH001/SX1231
/**************************************************************************//**
 * @brief   RTC Interrupt handler which toggles GPIO pin.
 *
 * @return  N/A
 *****************************************************************************/
void RTC_IRQHandler(void)
{
  /* Clear interrupt source */
  RTC_IntClear(RTC_IF_COMP0);

  /* Toggle GPIO pin. */
  GPIO_PinOutToggle((GPIO_Port_TypeDef)gpioPortNo, gpioPinNo );
}
コード例 #6
0
ファイル: bsp_timer.c プロジェクト: tsteinholz/network_tester
void bsp_increment_timer_tick(void)
{
    s_timer_tick++;

#ifdef BSP_TEST_TIMER_TICK
    GPIO_PinOutToggle(MICRO_IO0_PORT, MICRO_IO0_PIN);
#endif
}
コード例 #7
0
ファイル: main.c プロジェクト: snashpo/Senior_Design
void GPIO_ODD_IRQHandler(void)
{
	uint16_t intFlags = GPIO_IntGet();
	/* clear flag for FIX interrupt */
	GPIO_IntClear(intFlags);
	GPIO_PinOutToggle(EXT_LED, RED_LED);
	fix_val++;
}
コード例 #8
0
ファイル: bsp_timer.c プロジェクト: tsteinholz/network_tester
void bsp_test_timer(void)
{
    // This will block indefinitely
    while (1)
    {
        bsp_delay_ms(50);
        GPIO_PinOutToggle(MICRO_IO1_PORT, MICRO_IO1_PIN);
    }
}
コード例 #9
0
ファイル: dev_led.c プロジェクト: bright-pan/smart-lock
/***************************************************************************//**
 * @brief
 *   Toggle the state of a LED
 *
 * @details
 *
 * @note
 *
 * @param[in] num
 *   LED number
 *
 ******************************************************************************/
void rt_hw_led_toggle(rt_uint8_t num)
{
    RT_ASSERT(num < LEDS_MAX_NUMBER);

#if defined(EFM32_G8XX_STK)
    GPIO_PinOutToggle(leds_list[num][0], leds_list[num][1]);
#elif (defined(EFM32_GXXX_DK) || defined(EFM32GG_DK3750))
{
    rt_uint16_t leds;

    leds = DVK_getLEDs() ^ (rt_uint16_t)(1 << num);
    DVK_setLEDs(leds);
}
#endif
}
コード例 #10
0
ファイル: main.c プロジェクト: snashpo/Senior_Design
void TIMER0_IRQHandler(void)
{
  //int32_t bmp180_raw;
  /* Store the interrupt flags before clearing */
  uint16_t intFlags = TIMER_IntGet(TIMER0);

  /* Clear the interrupt flags. Only clear the flags that were stored in */
  /* intFlags in case other flags have been set since then */
  TIMER_IntClear(TIMER0, intFlags);

  /* Overflow interrupt occurred */
  if(intFlags & TIMER_IF_OF)
  {
	  GPIO_PinOutToggle(LED_PORT, LED0_PIN );                             // turn on LED0
	  GPIO_PinOutToggle(LED_PORT, LED1_PIN );                             // turn on LED0
	 //GPIO_PinOutToggle(EXT_LED, YEL_LED);
	 // GPIO_PinOutToggle(LED_PORT, LED1_PIN );
	 // GPIO_PinOutToggle(LED_PORT, OPLED_PIN);

	  timeout++;

	  counter = counter + 1;
	  if(counter > 10) {		//count to 10. then check to see how many fix vals have occured.
		  if(fix_val < 3) {		//if fix_val is greater than 2, then no fix. If less than 2, then solid fix
		  		  fix_val = 0;
		  		  satfix = 1;		//solid fix, so notify
		  	  }
		  else {
			  satfix = 0;
		  }
		  counter = 0;		//reset counter
	  }

  }

}
コード例 #11
0
ファイル: blink.c プロジェクト: jeromegros/TD1208
/***************************************************************************//**
 * @brief
 *   User setup function.
 ******************************************************************************/
void TD_USER_Setup(void)
{
	// Define the LED pin as an output in push-pull mode
	GPIO_PinModeSet(LED_PORT, LED_BIT, gpioModePushPull, 1);

	// Forever
	while (true) {

		// Toggle the LED pin on/off
		GPIO_PinOutToggle(LED_PORT, LED_BIT);

		// Delay 500 ms
		TD_RTC_Delay(T500MS);
	}

	// Never reached
}
コード例 #12
0
ファイル: main.c プロジェクト: snashpo/Senior_Design
int main () {

	CHIP_Init();				//Initialize Chip

	initMCU();
	initGPIO();				//Initialize GPIO
	sdi2c_Init();				//Initialize I2C
	initTimer();		//initialize timer for timer interuprt

	/* Setup SysTick Timer for 10 msec interrupts  */
	if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) {
	while (1) ;
	}

	/*Enable all sensors and GPS */
	GPIO_PinOutSet(GPS_PORT, ENABLE);			//Enable GPS Sensor board
	BMP180_GetCalData();		//Enable and get calibration data from BMP180
	initLSM303_LowPower();		//Enable Accel in low power mode
	initL3GD20H_Normal();			//Enable Gyro in normal mode
	GPIO_PinOutToggle(EXT_LED, YEL_LED);

	/* Acceleromter Data */
	Delay(10);
	LSM303_GetAccelData();
	LSM303_PowerOff();
	GPIO_PinOutToggle(EXT_LED, YEL_LED);

	/*Gyroscope Data */
	Delay(10);
	L3GD20H_GetGyroData();
	L3GD20H_PowerOff();
	GPIO_PinOutToggle(EXT_LED, YEL_LED);

	/*Temperature/Barometric Pressure */
	Delay(10);
	BMP180_GetTemp();
	BMP180_GetPressure();
	BMP180_CalcRealTemperature();
	BMP180_CalcRealPressure();
	GPIO_PinOutToggle(EXT_LED, YEL_LED);

	/*Power Sensor*/
	INA219_GetVoltage();
	GPIO_PinOutClear(EXT_LED, YEL_LED);

	GPIO_PinOutToggle(EXT_LED, GRE_LED);
	Delay(100);
	GPIO_PinOutToggle(EXT_LED, GRE_LED);


	/* GPS Information */
	timeout = 0;		//reset timeout
	initGPS();		//Initialize GPS UART
	coldrestart();		//Send cold restart command
	while(fullread == 0) {		//while not a full read, do the following
		if(satfix == 1) {			//if there is a satellite fix, then...
			GPIO_PinOutSet(EXT_LED, YEL_LED);		//toggle LED for debug
			readdata();		//readdata
			timeout = 0;
		}
		if(timeout > 20) {
			GPIO_PinOutClear(EXT_LED, YEL_LED);
			GPStimeout();
			break;
		}
	}

	GPIO_PinOutSet(EXT_LED, GRE_LED);
	Delay(500);

	printGPS(0);		//Print GPS to screen for debug

	concact();


	/* Infinite loop */
	while(1) {
	  if(GPIO_PinInGet(BUT_PORT, RIGHT_BUT) == 0) {
		  r = r + 1;
		  if(r > 2) {		//wrap around to beginning
			  r = 0;
		  }
		  printGPS(r);
	  }
	  if(GPIO_PinInGet(BUT_PORT, LEFT_BUT) == 0) {
			  r = r - 1;
			  if(r < 0) {		//wrap around to beginning
				  r = 2;
			  }
			  printSENSORS();
		  }
//	  if(GPIO_PinInGet(GPS_PORT, FIX) == 1) {
//		  GPIO_PinOutToggle(EXT_LED, RED_LED);
//	  }
	}
}
コード例 #13
0
void led_toggle(unsigned char led_nr)
{
    GPIO_PinOutToggle(leds[led_nr].port, leds[led_nr].pin);
}
コード例 #14
0
ファイル: gpio.c プロジェクト: basilfx/EFM2Riot
void gpio_toggle(gpio_t pin)
{
    GPIO_PinOutToggle(_port_num(pin), _pin_num(pin));
}
コード例 #15
0
ファイル: FPGAController.c プロジェクト: havardh/bitless
void FPGA_ToggleClock(void) {
    // Toggle the FPGA Sample Clock
    GPIO_PinOutToggle(gpioPortF, 12);
}
コード例 #16
0
void qk_gpio_toggle_pin(qk_gpio_pin pin)
{
	GPIO_PinOutToggle((GPIO_Port_TypeDef) _QK_GPIO_PORT(pin),
	                  (unsigned int) _QK_GPIO_BIT(pin));
}
コード例 #17
0
/**************************************************************************//**
 * @brief
 *   Called on USB transfer completion callback. Will qualify and parse a
 *   Command Block Wrapper (CBW).
 *
 * @param[in] status
 *   The transfer status.
 *
 * @param[in] xferred
 *   Number of bytes actually transferred.
 *
 * @param[in] remaining
 *   Number of bytes not transferred.
 *
 * @return
 *   USB_STATUS_OK.
 *****************************************************************************/
static int CbwCallback(USB_Status_TypeDef status,
                       uint32_t xferred, uint32_t remaining)
{
  (void) remaining;

  if ((msdState == MSDD_WAITFOR_CBW) &&
      (status == USB_STATUS_OK) &&
      (xferred == CBW_LEN) &&
      (CswValid()) &&
      (CswMeaningful()))
  {
    if ( ledPort != -1 )
      GPIO_PinOutToggle((GPIO_Port_TypeDef)ledPort, ledPin);

    /* Check the SCSI command descriptor block (CDB) */
    ProcessScsiCdb();

    if (pCmdStatus->valid)
      pCsw->bCSWStatus = USB_CLASS_MSD_CSW_CMDPASSED;
    else
      pCsw->bCSWStatus = USB_CLASS_MSD_CSW_CMDFAILED;

    pCsw->dCSWSignature   = CSW_SIGNATURE;
    pCsw->dCSWTag         = pCbw->dCBWTag;
    pCsw->dCSWDataResidue = pCbw->dCBWDataTransferLength;

    /* Check the "thirteen cases" */

    if ((pCbw->dCBWDataTransferLength != 0) &&
        (pCbw->Direction != pCmdStatus->direction))
    {
      /* Handle cases 8 and 10 */
      pCsw->bCSWStatus = USB_CLASS_MSD_CSW_PHASEERROR;

      if (pCbw->Direction)
      {
        /* Host expects to receive data, case 8 */
        USBD_StallEp(BULK_IN);
        msdState = MSDD_WAIT_FOR_INUNSTALLED;
      }
      else
      {
        /* Host expects to send data, case 10 */
        USBD_StallEp(BULK_OUT);
        SendCsw();
        msdState = MSDD_IDLE;
      }
    }

    else if (pCbw->Direction || (pCbw->dCBWDataTransferLength == 0))
    {
      /* SCSI IN commands or commands without data phase */
      /* Handle cases 1-7 */

      if (pCbw->dCBWDataTransferLength == 0)
      {
        /* Host expects no data, case 1, 2 or 3 */
        if (pCmdStatus->xferLen)
        {
          /* Device has data to transmit, case 2 & 3 */
          pCsw->bCSWStatus = USB_CLASS_MSD_CSW_PHASEERROR;
        }

        if ((pCmdStatus->xferLen == 0) &&
            (pCmdStatus->xferType == XFER_INDIRECT))
        {
          /* Commands with no data phase which require timeconsuming  */
          /* processing are executed in MSDD_Handler()                */
          msdState = MSDD_DO_CMD_TASK;
        }
        else
        {
          SendCsw();
          EnableNextCbw();
          msdState = MSDD_WAITFOR_CBW;
        }
      }
      else if (pCbw->dCBWDataTransferLength == pCmdStatus->xferLen)
      {
        /* Host and device agree on transferlength, case 6 */
        /* Send data to host */
        msdState = MSDD_SEND_CSW;
        XferBotData(pCmdStatus->xferLen);
      }
      else if (pCbw->dCBWDataTransferLength > pCmdStatus->xferLen)
      {
        /* Host expects more data than device can provide, case 4 and 5 */

        if (pCmdStatus->xferLen > 0)
        {
          /* Device has data, case 5 */
          /* Send data to host */
          msdState = MSDD_STALL_IN;
          XferBotData(pCmdStatus->xferLen);
        }
        else
        {
          /* Device has no data, case 4 */
          USBD_StallEp(BULK_IN);
          msdState = MSDD_WAIT_FOR_INUNSTALLED;
        }
      }
      else
      {
        /* Host expects less data than device will provide, case 7 */
        pCsw->bCSWStatus = USB_CLASS_MSD_CSW_PHASEERROR;
        /* Send data to host */
        msdState = MSDD_SEND_CSW;
        XferBotData(pCbw->dCBWDataTransferLength);
      }
    }

    else /* Host Direction is OUT and Host transferlength > 0 */
    {
      /* SCSI OUT commands */
      /* Handle cases 9, 11, 12 and 13 */

      if (pCbw->dCBWDataTransferLength == pCmdStatus->xferLen)
      {
        /* Host and device agree on transferlength, case 12 */

        /* Read data from host */
        msdState = MSDD_SEND_CSW;
        XferBotData(pCmdStatus->xferLen);
      }
      else if (pCbw->dCBWDataTransferLength > pCmdStatus->xferLen)
      {
        /* Host intend to send more data than device expects, case 9 & 11 */
        pCsw->bCSWStatus = USB_CLASS_MSD_CSW_CMDFAILED;
        USBD_StallEp(BULK_OUT);
        SendCsw();
        msdState = MSDD_IDLE;
      }
      else
      {
        /* Host has less data than device expects to receive, case 13 */
        pCsw->bCSWStatus = USB_CLASS_MSD_CSW_PHASEERROR;
        USBD_StallEp(BULK_OUT);
        SendCsw();
        msdState = MSDD_IDLE;
      }
    }
    return USB_STATUS_OK;
  }

  if ((status == USB_STATUS_OK) &&
      (USBD_GetUsbState() == USBD_STATE_CONFIGURED))
  {
    /* Stall both Ep's and wait for reset recovery */
    USBD_StallEp(BULK_OUT);
    USBD_StallEp(BULK_IN);
    msdState = MSDD_WAITFOR_RECOVERY;
  }

  return USB_STATUS_OK;
}
コード例 #18
0
/**************************************************************************//**
 * @brief Toggle LED, switch from on to off or vice versa
 *****************************************************************************/
void LED_Toggle(void)
{
  GPIO_PinOutToggle(LED_GPIO_PORT, LED_GPIO_PIN);
}
コード例 #19
0
ファイル: scheduler_blink.c プロジェクト: jeromegros/TD1208
/***************************************************************************//**
 * @brief
 *  LED blinking. This function is being called by the Scheduler.
 *
 * @param[in] arg
 *  Argument passed by the Scheduler.
 *
 * @param[in] repetition
 *  Argument passed by the Scheduler.
 ******************************************************************************/
static void LedBlink(uint32_t arg, uint8_t repetition)
{
	GPIO_PinOutToggle(TIM2_PORT, TIM2_BIT);
}