• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PIO_Configure函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: SensorsTestInit

void SensorsTestInit()
{
	char pinDirection = 0;
	int i;
	PIO_Configure(aDigitalOuts, PIO_LISTSIZE(aDigitalOuts));
	PIO_Configure(digitalIns, PIO_LISTSIZE(digitalIns));
	PIO_Configure(sensorsPower, PIO_LISTSIZE(sensorsPower));
	
	PMC_EnablePeripheral(AT91C_ID_PIOB);
	PMC_EnablePeripheral(AT91C_ID_PIOA);
	
	SelectAng0();		// select analog port 0 to be mesured instead of BattVoltage
	SensorPowerOn();	// turn on the Vcc line
	
	if(PMC_IsPeriphEnabled(AT91C_ID_TWI) == 0){
		PIO_Configure(twiPortPins, PIO_LISTSIZE(twiPortPins));
		PMC_EnablePeripheral(AT91C_ID_TWI);
		
		TWI_ConfigureMaster(AT91C_BASE_TWI,TWCK,MCK);
	}
	
	// set all pins on pullup chip to output
	WritePullupData(0x00,&pinDirection,1);
	WritePullupData(0x01,&pinDirection,1);
	
	for(i = 0;i < 8;i++){
		if(i>1) AnalogPullup(i,0);  // disable Analog pullups for output test
		DigitalPullup(i,1);		// enable all digital pullups
	}
}
开发者ID:BotBallARDroneAPI,项目名称:CBC_Library,代码行数:30,代码来源:sensors.c


示例2: PIO_Configure

//------------------------------------------------------------------------------
void SdSpi::begin() {
  PIO_Configure(
      g_APinDescription[PIN_SPI_MOSI].pPort,
      g_APinDescription[PIN_SPI_MOSI].ulPinType,
      g_APinDescription[PIN_SPI_MOSI].ulPin,
      g_APinDescription[PIN_SPI_MOSI].ulPinConfiguration);
  PIO_Configure(
      g_APinDescription[PIN_SPI_MISO].pPort,
      g_APinDescription[PIN_SPI_MISO].ulPinType,
      g_APinDescription[PIN_SPI_MISO].ulPin,
      g_APinDescription[PIN_SPI_MISO].ulPinConfiguration);
  PIO_Configure(
      g_APinDescription[PIN_SPI_SCK].pPort,
      g_APinDescription[PIN_SPI_SCK].ulPinType,
      g_APinDescription[PIN_SPI_SCK].ulPin,
      g_APinDescription[PIN_SPI_SCK].ulPinConfiguration);
  pmc_enable_periph_clk(ID_SPI0);
#if USE_SAM3X_DMAC
  pmc_enable_periph_clk(ID_DMAC);
  dmac_disable();
  DMAC->DMAC_GCFG = DMAC_GCFG_ARB_CFG_FIXED;
  dmac_enable();
#if USE_SAM3X_BUS_MATRIX_FIX
  MATRIX->MATRIX_WPMR = 0x4d415400;
  MATRIX->MATRIX_MCFG[1] = 1;
  MATRIX->MATRIX_MCFG[2] = 1;
  MATRIX->MATRIX_SCFG[0] = 0x01000010;
  MATRIX->MATRIX_SCFG[1] = 0x01000010;
  MATRIX->MATRIX_SCFG[7] = 0x01000010;
#endif  // USE_SAM3X_BUS_MATRIX_FIX
#endif  // USE_SAM3X_DMAC
}
开发者ID:nauman-naeem,项目名称:SdFat-beta,代码行数:33,代码来源:SdSpiSAM3X.cpp


示例3: PIO_Configure

   // hardware SPI
   void HAL::spiBegin()
   {
        // Configre SPI pins
        PIO_Configure(
           g_APinDescription[SCK_PIN].pPort,
           g_APinDescription[SCK_PIN].ulPinType,
           g_APinDescription[SCK_PIN].ulPin,
           g_APinDescription[SCK_PIN].ulPinConfiguration);
        PIO_Configure(
           g_APinDescription[MOSI_PIN].pPort,
           g_APinDescription[MOSI_PIN].ulPinType,
           g_APinDescription[MOSI_PIN].ulPin,
           g_APinDescription[MOSI_PIN].ulPinConfiguration);
        PIO_Configure(
           g_APinDescription[MISO_PIN].pPort,
           g_APinDescription[MISO_PIN].ulPinType,
           g_APinDescription[MISO_PIN].ulPin,
           g_APinDescription[MISO_PIN].ulPinConfiguration);

        // set master mode, peripheral select, fault detection
        SPI_Configure(SPI0, ID_SPI0, SPI_MR_MSTR | 
                     SPI_MR_MODFDIS | SPI_MR_PS);
       SPI_Enable(SPI0);
        PIO_Configure(
           g_APinDescription[SPI_PIN].pPort,
           g_APinDescription[SPI_PIN].ulPinType,
           g_APinDescription[SPI_PIN].ulPin,
           g_APinDescription[SPI_PIN].ulPinConfiguration);
        spiInit(1);
   }
开发者ID:KristoZ,项目名称:Repetier-Firmware,代码行数:31,代码来源:HAL.cpp


示例4: pmc_enable_periph_clk

/*************************************************************************
 Initialization of the I2C bus interface. Need to be called only once
*************************************************************************/
void HAL::i2cInit(unsigned long clockSpeedHz)
{
  // enable TWI
  pmc_enable_periph_clk(TWI_ID);

  // Configure pins
#if SDA_PIN >= 0
  PIO_Configure(g_APinDescription[SDA_PIN].pPort,
                g_APinDescription[SDA_PIN].ulPinType,
                g_APinDescription[SDA_PIN].ulPin,
                g_APinDescription[SDA_PIN].ulPinConfiguration);
#endif
#if SCL_PIN >= 0
  PIO_Configure(g_APinDescription[SCL_PIN].pPort,
                g_APinDescription[SCL_PIN].ulPinType,
                g_APinDescription[SCL_PIN].ulPin,
                g_APinDescription[SCL_PIN].ulPinConfiguration);
#endif
 /*
  // Set to Master mode with known state
  TWI_INTERFACE->TWI_CR = TWI_CR_SVEN;
  TWI_INTERFACE->TWI_CR = TWI_CR_SWRST;
  //TWI_INTERFACE->TWI_RHR;  // no action???
  TWI_INTERFACE->TWI_IMR = 0;

  TWI_INTERFACE->TWI_CR = TWI_CR_SVDIS;
  TWI_INTERFACE->TWI_CR = TWI_CR_MSDIS;
  TWI_INTERFACE->TWI_CR = TWI_CR_MSEN;   */
  // Set to Master mode with known state
  TWI_INTERFACE->TWI_CR = TWI_CR_SWRST;// Reset
  TWI_INTERFACE->TWI_CR = TWI_CR_SVDIS;// Slave disable
  TWI_INTERFACE->TWI_CR = TWI_CR_MSEN; //Master enable
  
  i2cSetClockspeed(clockSpeedHz);
}
开发者ID:luc-github,项目名称:Repetier-Firmware-0.92,代码行数:38,代码来源:HAL.cpp


示例5: AccelInit

unsigned char AccelInit(void)
{	
	PIO_Configure(accIntPins, PIO_LISTSIZE(accIntPins));
	
	if(PMC_IsPeriphEnabled(AT91C_ID_TWI) == 0){
		PIO_Configure(twiPins, PIO_LISTSIZE(twiPins));
		
		PMC_EnablePeripheral(AT91C_ID_TWI);
	
		TWI_ConfigureMaster(AT91C_BASE_TWI,TWCK,MCK);
	}
	usleep(10000);

#ifdef STACCEL
	// ST Accelerometer
	char setup[4];
	setup[0] = (1<<5)|(2<<3)|7; // Normal power, data rate = 400Hz, ZYX axis enabled
	setup[1] = 0; // Do not add filter stuff
	setup[2] = (2<<0); // Data ready interrupt on INT 2 pad
	setup[3] = (0<<4); // do update between reads, and set scale to +/- 2g's
	WriteAccelData(0x20|(1<<7),setup,4);
#else
	// Freescale Accelerometer
	//AccelCalibration();	
	AccelSetScale(2);	
	AccelSetCalibration();
	
#endif
	SetPitCallback(AccelCallback,3);
	
	return 0;
}
开发者ID:BotBallARDroneAPI,项目名称:CBC_Library,代码行数:32,代码来源:accel.c


示例6: glcd_init

//---------------------------
void glcd_init(void)
{
	unsigned int tcmr,tfmr;
	unsigned char i;
  
  PIO_Configure(GLcdpins,PIO_LISTSIZE(GLcdpins));
	PIO_Configure(sscPins, PIO_LISTSIZE(sscPins));	
	
	PIO_Set(&GLcdpins[3]);
	PIO_Set(&GLcdpins[4]);
	
	SSC_Configure(AT91C_BASE_SSC,AT91C_ID_SSC,500000,BOARD_MCK);
    
  tcmr=AT91C_SSC_CKS_TK|AT91C_SSC_CKO_DATA_TX|AT91C_SSC_START_CONTINOUS;
  tfmr=SSC_DATLEN(8)|SSC_DATNB(15)|SSC_FSLEN(16)|AT91C_SSC_FSOS_LOW|AT91C_SSC_FSDEN ;
    
  SSC_ConfigureTransmitter(AT91C_BASE_SSC,tcmr,tfmr);
  SSC_EnableTransmitter(AT91C_BASE_SSC);
	
	PIO_Set(&GLcdpins[5]); 
  //PIO_Clear(&GLcdpins[5]);
	for(i = 0; i < 3; i++);
  GLCD_WriteCommand((DISPLAY_ON_CMD | ON), i);
	
}	
开发者ID:naminic,项目名称:Grafical-Lcd-Arm,代码行数:26,代码来源:glcd.c


示例7: _ILI9488_Spi_HW_Initialize

/**
 * \brief ILI9488 Hardware Initialization for SPI/SMC LCD.
 */
static void _ILI9488_Spi_HW_Initialize(void)
{
	/* Pin configurations */
	PIO_Configure(&lcd_spi_reset_pin, 1);
	PIO_Configure(&lcd_spi_cds_pin, 1);
	PIO_Configure(lcd_pins, PIO_LISTSIZE(lcd_pins));
	PIO_Configure(&lcd_spi_pwm_pin, 1);

	/* Enable PWM peripheral clock */
	PMC_EnablePeripheral(ID_PWM0);
	PMC_EnablePeripheral(ID_SPI0);
	/* Set clock A and clock B */
	// set for 14.11 KHz for CABC control
	//mode = PWM_CLK_PREB(0x0A) | (PWM_CLK_DIVB(110)) |
	//PWM_CLK_PREA(0x0A) | (PWM_CLK_DIVA(110));
	PWMC_ConfigureClocks(PWM0, 14200, 0,  BOARD_MCK);

	/* Configure PWM channel 1 for LED0  */
	PWMC_DisableChannel(PWM0, CHANNEL_PWM_LCD);

	PWMC_ConfigureChannel(PWM0, CHANNEL_PWM_LCD, PWM_CMR_CPRE_CLKA, 0,
						  PWM_CMR_CPOL);
	PWMC_SetPeriod(PWM0, CHANNEL_PWM_LCD, 16);
	PWMC_SetDutyCycle(PWM0, CHANNEL_PWM_LCD, 8);
	PWMC_EnableChannel(PWM0, CHANNEL_PWM_LCD);

	SPI_Configure(ILI9488_SPI, ID_SPI0, (SPI_MR_MSTR | SPI_MR_MODFDIS
										 | SPI_PCS(SMC_EBI_LCD_CS)));
	SPI_ConfigureNPCS(ILI9488_SPI,
					  SMC_EBI_LCD_CS,
					  SPI_CSR_CPOL | SPI_CSR_BITS_8_BIT | SPI_DLYBS(6, BOARD_MCK)
					  | SPI_DLYBCT(100, BOARD_MCK) | SPI_SCBR(20000000, BOARD_MCK));
	SPI_Enable(ILI9488_SPI);
}
开发者ID:codingzhouk,项目名称:LiteOS_Kernel,代码行数:37,代码来源:ili9488_spi.c


示例8: ADS7843_Initialize

/**
 * \brief Initialization of the SPI for communication with ADS7843 component.
 */
extern void ADS7843_Initialize( void )
{
    volatile uint32_t uDummy;

    /* Configure pins */
    PIO_Configure(pinsSPI, PIO_LISTSIZE(pinsSPI));

    PIO_Configure(pinBusy, PIO_LISTSIZE(pinBusy));

    SPI_Configure(BOARD_TSC_SPI_BASE,
                  BOARD_TSC_SPI_ID,
                  SPI_MR_MSTR | SPI_MR_MODFDIS | SPI_PCS(BOARD_TSC_NPCS) /* Value of the SPI configuration register. */
    );

    SPI_ConfigureNPCS(BOARD_TSC_SPI_BASE, BOARD_TSC_NPCS,
                      SPI_CSR_NCPHA | SPI_CSR_DLYBS(DELAY_BEFORE_SPCK) |
                      SPI_CSR_DLYBCT(DELAY_BETWEEN_CONS_COM) | SPI_CSR_SCBR(0xC8) );

    SPI_Enable(BOARD_TSC_SPI_BASE);

    for (uDummy=0; uDummy<100000; uDummy++);

    uDummy = REG_SPI_SR;
    uDummy = REG_SPI_RDR;

    SendCommand(CMD_ENABLE_PENIRQ);
}
开发者ID:tjohann,项目名称:sam3_p256_libboard,代码行数:30,代码来源:ads7843.c


示例9: stepper_set_output_current

void stepper_set_output_current(const uint16_t current) {
	Pin pin = PIN_PWR_DAC;
	const uint16_t new_current = BETWEEN(VREF_RES_MIN_CURRENT,
	                                     current,
	                                     VREF_MAX_CURRENT);

	if(new_current < VREF_RES_MAX_CURRENT) {
		pin.type = PIO_OUTPUT_0;
		pin.attribute = PIO_DEFAULT;
		PIO_Configure(&pin, 1);
		DACC_SetConversionData(DACC, SCALE(new_current,
		                                   VREF_RES_MIN_CURRENT,
	                                       VREF_RES_MAX_CURRENT,
	                                       VOLTAGE_MIN_VALUE,
	                                       VOLTAGE_MAX_VALUE));
	} else {
		DACC_SetConversionData(DACC, SCALE(new_current,
		                                   VREF_MIN_CURRENT,
	                                       VREF_MAX_CURRENT,
	                                       VOLTAGE_MIN_VALUE,
	                                       VOLTAGE_MAX_VALUE));
		pin.type = PIO_INPUT;;
		pin.attribute = PIO_DEFAULT;
		PIO_Configure(&pin, 1);
	}

	stepper_output_current = new_current;
}
开发者ID:Nic2012,项目名称:stepper-brick,代码行数:28,代码来源:stepper.c


示例10: spiBegin

//------------------------------------------------------------------------------
void spiBegin(uint8_t csPin) {
  pinMode(csPin,OUTPUT);
  digitalWrite(csPin,HIGH);
  PIO_Configure(
      g_APinDescription[PIN_SPI_MOSI].pPort,
      g_APinDescription[PIN_SPI_MOSI].ulPinType,
      g_APinDescription[PIN_SPI_MOSI].ulPin,
      g_APinDescription[PIN_SPI_MOSI].ulPinConfiguration);
  PIO_Configure(
      g_APinDescription[PIN_SPI_MISO].pPort,
      g_APinDescription[PIN_SPI_MISO].ulPinType,
      g_APinDescription[PIN_SPI_MISO].ulPin,
      g_APinDescription[PIN_SPI_MISO].ulPinConfiguration);
  PIO_Configure(
      g_APinDescription[PIN_SPI_SCK].pPort,
      g_APinDescription[PIN_SPI_SCK].ulPinType,
      g_APinDescription[PIN_SPI_SCK].ulPin,
      g_APinDescription[PIN_SPI_SCK].ulPinConfiguration);
  pmc_enable_periph_clk(ID_SPI0);
#if USE_SAM3X_DMAC
  pmc_enable_periph_clk(ID_DMAC);
  dmac_disable();
  DMAC->DMAC_GCFG = DMAC_GCFG_ARB_CFG_FIXED;
  dmac_enable();
#if USE_SAM3X_BUS_MATRIX_FIX
  MATRIX->MATRIX_WPMR = 0x4d415400;
  MATRIX->MATRIX_MCFG[1] = 1;
  MATRIX->MATRIX_MCFG[2] = 1;
  MATRIX->MATRIX_SCFG[0] = 0x01000010;
  MATRIX->MATRIX_SCFG[1] = 0x01000010;
  MATRIX->MATRIX_SCFG[7] = 0x01000010;
#endif  // USE_SAM3X_BUS_MATRIX_FIX
#endif  // USE_SAM3X_DMAC
}
开发者ID:ravesky,项目名称:ADS129x-tools,代码行数:35,代码来源:SpiDma.cpp


示例11: motors_init

void motors_init()
{
  PIO_Configure(&pin_m0_en, 1);
  PIO_Configure(&pin_m1_en, 1);
  PIO_Configure(&pin_m2_en, 1);
  PIO_Configure(&pin_m_brake, 1);
  PIO_Configure(&pin_m0_dir, 1);
  PIO_Configure(&pin_m1_dir, 1);
  PIO_Configure(&pin_m2_dir, 1);
  PMC_EnablePeripheral(ID_PWM); // power up pwm controller plz
  PIO_Configure(&pin_m0_vref, 1); // PWML0
  PIO_Configure(&pin_m1_vref, 1); // PWMH1
  PIO_Configure(&pin_m2_vref, 1); // PWMH3
  PWM->PWM_CH_NUM[0].PWM_CMR = 0; // pass-through divider. 64 MHz clock.
  PWM->PWM_CH_NUM[0].PWM_CPRD = 255; // 8-bit current control, 125 kHz cycle 
  PWM->PWM_CH_NUM[0].PWM_CDTY = 0; // zero duty for now
  PWM->PWM_CH_NUM[1].PWM_CMR = 0; 
  PWM->PWM_CH_NUM[1].PWM_CPRD = 255; 
  PWM->PWM_CH_NUM[1].PWM_CDTY = 255;
  PWM->PWM_CH_NUM[3].PWM_CMR = 0;
  PWM->PWM_CH_NUM[3].PWM_CPRD = 255;
  PWM->PWM_CH_NUM[3].PWM_CDTY = 255;
  PWM->PWM_ENA = 0xb; // enable channels 0,1,3
  PIO_Set(&pin_m_brake);
  PIO_Set(&pin_m0_en);
  PIO_Set(&pin_m1_en);
  PIO_Set(&pin_m2_en);
}
开发者ID:jinpyojeon,项目名称:TRIN_EARL,代码行数:28,代码来源:motors.c


示例12: ILI9488_InitInterface

static void ILI9488_InitInterface(void)
{

    PIO_Configure(ILI9488_Reset, PIO_LISTSIZE(ILI9488_Reset));    
    PIO_Configure(spi_pins, PIO_LISTSIZE(spi_pins));


    PIO_Configure(ILI9488_Pwm, PIO_LISTSIZE(ILI9488_Pwm));
    /* Enable PWM peripheral clock */
    PMC_EnablePeripheral(ID_PWM0);

    /* Set clock A and clock B */
    // set for 14.11 KHz for CABC control
    //    mode = PWM_CLK_PREB(0x0A) | (PWM_CLK_DIVB(110)) | 
    //           PWM_CLK_PREA(0x0A) | (PWM_CLK_DIVA(110));
    PWMC_ConfigureClocks(PWM0, 14200, 0,  BOARD_MCK);

    /* Configure PWM channel 1 for LED0  */
    PWMC_DisableChannel(PWM0, CHANNEL_PWM_LCD);

    PWMC_ConfigureChannel(PWM0, CHANNEL_PWM_LCD, PWM_CMR_CPRE_CLKA,0,PWM_CMR_CPOL);
    PWMC_SetPeriod(PWM0, CHANNEL_PWM_LCD, 16);
    PWMC_SetDutyCycle(PWM0, CHANNEL_PWM_LCD, 8);
    PWMC_EnableChannel(PWM0, CHANNEL_PWM_LCD);

    SPI_Configure(ILI9488, ILI9488_ID, (SPI_MR_MSTR | SPI_MR_MODFDIS | SPI_PCS( ILI9488_cs )));
    SPI_ConfigureNPCS( ILI9488, ILI9488_cs, 
            SPI_CSR_CPOL | SPI_CSR_BITS_9_BIT | 
            SPI_DLYBS(100, BOARD_MCK) | SPI_DLYBCT(100, BOARD_MCK) |
            SPI_SCBR( 35000000, BOARD_MCK) ) ;  

    SPI_Enable(ILI9488);

}
开发者ID:BlueSkyGjj,项目名称:SAMV71_softpack,代码行数:34,代码来源:ili9488.c


示例13: UART_Configure

extern void UART_Configure( uint32_t baudrate, uint32_t masterClock)
{
#if 0
    const Pin pPins[] = CONSOLE_PINS;

    /* Configure PIO */
    PIO_Configure(pPins, PIO_LISTSIZE(pPins));

    uint32_t mode = US_MR_USART_MODE_RS485 | US_MR_USCLKS_MCK
                    | US_MR_CHRL_8_BIT | US_MR_PAR_NO | US_MR_NBSTOP_1_BIT
                    | US_MR_CHMODE_NORMAL;

    PMC->PMC_PCER0 = 1 << CONSOLE_ID;

    USART_Configure( USART1, mode, CONSOLE_BAUDRATE, BOARD_MCK ) ;

    USART1->US_IDR = 0xFFFFFFFF ;

    NVIC_EnableIRQ( USART1_IRQn ) ;
    USART_SetTransmitterEnabled( USART1, 1 ) ;
#else

#ifdef CONSOLE_USART_USE_UART1
    const Pin pPins[] = {{1 << 3, PIOB, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT}};
    Uart *pUart = CONSOLE_USART;
#else
    const Pin pPins[] = CONSOLE_PINS;
    Uart *pUart = (Uart *)CONSOLE_USART;
#endif
    /* Configure PIO */
    PIO_Configure(pPins, PIO_LISTSIZE(pPins));

    /* Configure PMC */
#ifdef CONSOLE_USART_USE_UART1
    PMC->PMC_PCER0 = 1 << ID_UART1;
#else
    PMC->PMC_PCER0 = 1 << CONSOLE_ID;
#endif

    /* Reset and disable receiver & transmitter */
    pUart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX
                   | UART_CR_RXDIS | UART_CR_TXDIS;

    /* Configure mode */
    pUart->UART_MR =  UART_MR_PAR_NO | US_MR_CHRL_8_BIT;

    /* Configure baudrate */
    /* Asynchronous, no oversampling */
    pUart->UART_BRGR = (masterClock / baudrate) / 16;

    /* Disable PDC channel */
    pUart->UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS;

    /* Enable receiver and transmitter */
    pUart->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
#endif
}
开发者ID:makerpc,项目名称:bricklib,代码行数:57,代码来源:uart_console.c


示例14: PIO_Configure

// Initialize ADC channels
void HAL::analogStart(void)
{

#if MOTHERBOARD == 500 || MOTHERBOARD == 501
  PIO_Configure(
    g_APinDescription[58].pPort,
    g_APinDescription[58].ulPinType,
    g_APinDescription[58].ulPin,
    g_APinDescription[58].ulPinConfiguration);
  PIO_Configure(
    g_APinDescription[59].pPort,
    g_APinDescription[59].ulPinType,
    g_APinDescription[59].ulPin,
    g_APinDescription[59].ulPinConfiguration);
#endif // (MOTHERBOARD==500) || (MOTHERBOARD==501)

  // ensure we can write to ADC registers
  ADC->ADC_WPMR = 0x41444300u; //ADC_WPMR_WPKEY(0);
  pmc_enable_periph_clk(ID_ADC);  // enable adc clock

  for (int i = 0; i < ANALOG_INPUTS; i++)
  {
    osAnalogInputValues[i] = 0;
    adcSamplesMin[i] = 100000;
    adcSamplesMax[i] = 0;
    adcEnable |= (0x1u << osAnalogInputChannels[i]);
    osAnalogSamplesSum[i] = 2048 * ANALOG_INPUT_MEDIAN;
    for (int j = 0; j < ANALOG_INPUT_MEDIAN; j++)
      osAnalogSamples[i][j] = 2048; // we want to prevent early error from bad starting values
  }
  // enable channels
  ADC->ADC_CHER = adcEnable;
  ADC->ADC_CHDR = !adcEnable;

  // Initialize ADC mode register (some of the following params are not used here)
  // HW trigger disabled, use external Trigger, 12 bit resolution
  // core and ref voltage stays on, normal sleep mode, normal not free-run mode
  // startup time 16 clocks, settling time 17 clocks, no changes on channel switch
  // convert channels in numeric order
  // set prescaler rate  MCK/((PRESCALE+1) * 2)
  // set tracking time  (TRACKTIM+1) * clock periods
  // set transfer period  (TRANSFER * 2 + 3)
  ADC->ADC_MR = ADC_MR_TRGEN_DIS | ADC_MR_TRGSEL_ADC_TRIG0 | ADC_MR_LOWRES_BITS_12 |
                ADC_MR_SLEEP_NORMAL | ADC_MR_FWUP_OFF | ADC_MR_FREERUN_OFF |
                ADC_MR_STARTUP_SUT64 | ADC_MR_SETTLING_AST17 | ADC_MR_ANACH_NONE |
                ADC_MR_USEQ_NUM_ORDER |
                ADC_MR_PRESCAL(AD_PRESCALE_FACTOR) |
                ADC_MR_TRACKTIM(AD_TRACKING_CYCLES) |
                ADC_MR_TRANSFER(AD_TRANSFER_CYCLES);

  ADC->ADC_IER = 0;             // no ADC interrupts
  ADC->ADC_CGR = 0;             // Gain = 1
  ADC->ADC_COR = 0;             // Single-ended, no offset

  // start first conversion
  ADC->ADC_CR = ADC_CR_START;
}
开发者ID:luc-github,项目名称:Repetier-Firmware-0.92,代码行数:58,代码来源:HAL.cpp


示例15: platform_pio_op

pio_type platform_pio_op( unsigned port, pio_type pinmask, int op )
{
  Pin* pin;
  pio_type retval = 1;
  
  pin = pio_port_desc + port;
  pin->mask = pinmask;
  switch( op )
  {
    case PLATFORM_IO_PORT_SET_VALUE:    
    case PLATFORM_IO_PIN_SET:
      PIO_Set( pin );
      break;
      
    case PLATFORM_IO_PIN_CLEAR:
      PIO_Clear( pin );
      break;
      
    case PLATFORM_IO_PORT_DIR_INPUT:
      pin->mask = 0x7FFFFFFF;      
    case PLATFORM_IO_PIN_DIR_INPUT:
      pin->type = PIO_INPUT;
      PIO_Configure( pin, 1 );
      break;
      
    case PLATFORM_IO_PORT_DIR_OUTPUT:      
      pin->mask = 0x7FFFFFFF;      
    case PLATFORM_IO_PIN_DIR_OUTPUT:
      pin->type = PIO_OUTPUT_0;
      PIO_Configure( pin, 1 );
      break;      
            
    case PLATFORM_IO_PORT_GET_VALUE:
      pin->mask = 0x7FFFFFFF;
      pin->type = PIO_INPUT;
      retval = PIO_Get( pin );
      break;
      
    case PLATFORM_IO_PIN_GET:
      retval = PIO_Get( pin ) & pinmask ? 1 : 0;
      break;
      
    case PLATFORM_IO_PIN_PULLUP:
      pin->pio->PIO_PPUER = pinmask;
      break;
      
    case PLATFORM_IO_PIN_NOPULL:
      pin->pio->PIO_PPUDR = pinmask;
      break;
      
    default:
      retval = 0;
      break;
  }
  return retval;
}
开发者ID:Theemuts,项目名称:eLuaBrain,代码行数:56,代码来源:platform.c


示例16: GPIO_Init

void GPIO_Init(void)
{  
  
    PIO_Configure( pinsSwitches,  PIO_LISTSIZE(pinsSwitches) );
    PIO_Configure( pinsGpios,    PIO_LISTSIZE(pinsGpios)     );          
    //PIO_InitializeInterrupts( AT91C_AIC_PRIOR_LOWEST );     
    //LED_Configure(LED_DS1);
    //LED_Configure(LED_DS2);
    
}
开发者ID:nustpq,项目名称:bridge_host,代码行数:10,代码来源:gpio.c


示例17: pinMode

extern void pinMode( uint32_t ulPin, uint32_t ulMode )
{
	if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN )
    {
        return ;
    }

    /* Added by Y.Ishioka */
    if( ulPin == 13 ) {
        led_init() ;
        led_set( 1 ) ;
        return ;
    }

	switch ( ulMode )
    {
        case INPUT:
            /* Enable peripheral for clocking input */
            pmc_enable_periph_clk( g_APinDescription[ulPin].ulPeripheralId ) ;
            PIO_Configure(
            	g_APinDescription[ulPin].pPort,
            	PIO_INPUT,
            	g_APinDescription[ulPin].ulPin,
            	0 ) ;
        break ;

        case INPUT_PULLUP:
            /* Enable peripheral for clocking input */
            pmc_enable_periph_clk( g_APinDescription[ulPin].ulPeripheralId ) ;
            PIO_Configure(
            	g_APinDescription[ulPin].pPort,
            	PIO_INPUT,
            	g_APinDescription[ulPin].ulPin,
            	PIO_PULLUP ) ;
        break ;

        case OUTPUT:
            PIO_Configure(
            	g_APinDescription[ulPin].pPort,
            	PIO_OUTPUT_1,
            	g_APinDescription[ulPin].ulPin,
            	g_APinDescription[ulPin].ulPinConfiguration ) ;

            /* if all pins are output, disable PIO Controller clocking, reduce power consumption */
            if ( g_APinDescription[ulPin].pPort->PIO_OSR == 0xffffffff )
            {
                pmc_disable_periph_clk( g_APinDescription[ulPin].ulPeripheralId ) ;
            }
        break ;

        default:
        break ;
    }
}
开发者ID:fujisakura,项目名称:Contributions,代码行数:54,代码来源:wiring_digital.c


示例18: GMACB_InitPhy

/**
 * \brief Do a HW initialize to the PHY (via RSTC) and set up clocks & PIOs
 * This should be called only once to initialize the PHY pre-settings.
 * The PHY address is reset status of CRS,RXD[3:0] (the emacPins' pullups).
 * The COL pin is used to select MII mode on reset (pulled up for Reduced MII)
 * The RXDV pin is used to select test mode on reset (pulled up for test mode)
 * The above pins should be predefined for corresponding settings in resetPins
 * The GMAC peripheral pins are configured after the reset done.
 * \param pMacb Pointer to the MACB instance
 * \param mck         Main clock setting to initialize clock
 * \param resetPins   Pointer to list of PIOs to configure before HW RESET
 *                       (for PHY power on reset configuration latch)
 * \param nbResetPins Number of PIO items that should be configured
 * \param emacPins    Pointer to list of PIOs for the EMAC interface
 * \param nbEmacPins  Number of PIO items that should be configured
 * \return 1 if RESET OK, 0 if timeout.
 */
uint8_t GMACB_InitPhy(GMacb *pMacb,
					  uint32_t mck,
					  const Pin *pResetPins,
					  uint32_t nbResetPins,
					  const Pin *pGmacPins,
					  uint32_t nbGmacPins)
{
	sGmacd *pDrv = pMacb->pGmacd;
	Gmac *pHw = pDrv->pHw;
	uint8_t rc = 1;
	uint8_t phy;

	/* Perform RESET */
	TRACE_DEBUG("RESET PHY\n\r");

	if (pResetPins) {
		/* Configure PINS */
		PIO_Configure(pResetPins, nbResetPins);
		TRACE_INFO(" Hard Reset of GMACD Phy\n\r");
		PIO_Clear(pResetPins);
		Wait(100);
		PIO_Set(pResetPins);
	}

	/* Configure GMAC runtime pins */
	if (rc) {

		PIO_Configure(pGmacPins, nbGmacPins);
		rc = GMAC_SetMdcClock(pHw, mck);

		if (!rc) {
			TRACE_ERROR("No Valid MDC clock\n\r");
			return 0;
		}

		/* Check PHY Address */
		phy = GMACB_FindValidPhy(pMacb);

		if (phy == 0xFF) {
			TRACE_ERROR("PHY Access fail\n\r");
			return 0;
		}

		if (phy != pMacb->phyAddress) {
			pMacb->phyAddress = phy;
			GMACB_ResetPhy(pMacb);
		}
	} else
		TRACE_ERROR("PHY Reset Timeout\n\r");

	return rc;
}
开发者ID:codingzhouk,项目名称:LiteOS_Kernel,代码行数:69,代码来源:gmacb_phy.c


示例19: act_driver_init

//Sets up PWM output
//use_accelerator pwm should generally not be turned on un
void act_driver_init() {

    //sets up driver pins

    if (use_normal_pwm) {
        PIO_Configure(&pwm0_pin, 1);
    } else {
        PIO_Configure(&pwm2_pin, 1);
    }
    PIO_Configure(&pwm1_pin, 1);


    // Enable PWMC peripheral clock
    AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PWMC; // Power up PWM Controller. 


    if (use_normal_pwm) {
        AT91C_BASE_PWMC->PWMC_DIS = AT91C_PWMC_CHID0; //disable channel 0 - ACT_DRIVER_CHANNEL_CLOCKWISE
    } else {
        AT91C_BASE_PWMC->PWMC_DIS = AT91C_PWMC_CHID2; // disable channel 2 - ACT_DRIVER_ALTERNATE_PWM
    }
    
    
    AT91C_BASE_PWMC->PWMC_DIS = AT91C_PWMC_CHID1; //disable channel 1 - ACT_DRIVER_CHANNEL_ANTICLOCKWISE


    AT91C_BASE_PWMC->PWMC_MR = 0; // Clear mode register.


    if (use_normal_pwm) {
        AT91C_BASE_PWMC->PWMC_CH[0].PWMC_CMR = 0x00 | AT91C_PWMC_CPOL; // use board frequency and polarity 0.
        AT91C_BASE_PWMC->PWMC_CH[0].PWMC_CPRDR = FULL_DUTY_PERIOD; //set the period
        set_pwm_duty_percent(/*channel*/ACT_DRIVER_CHANNEL_CLOCKWISE,0);
    } else {
        AT91C_BASE_PWMC->PWMC_CH[2].PWMC_CMR = 0x00 | AT91C_PWMC_CPOL; // MCK and polarity 0.
        AT91C_BASE_PWMC->PWMC_CH[2].PWMC_CPRDR = FULL_DUTY_PERIOD; //set the period
        set_pwm_duty_percent(/*channel*/ACT_DRIVER_CHANNEL_ALTERNATE,0);
    }

    AT91C_BASE_PWMC->PWMC_CH[1].PWMC_CMR = 0x00 | AT91C_PWMC_CPOL; // MCK and polarity 0.
    AT91C_BASE_PWMC->PWMC_CH[1].PWMC_CPRDR = FULL_DUTY_PERIOD; //set the period
    set_pwm_duty_percent(/*channel*/ACT_DRIVER_CHANNEL_ANTICLOCKWISE,0);


    if (use_normal_pwm) {
        AT91C_BASE_PWMC->PWMC_ENA = AT91C_PWMC_CHID0; // Enable channel 0.
    } else {
        AT91C_BASE_PWMC->PWMC_ENA = AT91C_PWMC_CHID2; // Enable channel 2
    }

    AT91C_BASE_PWMC->PWMC_ENA = AT91C_PWMC_CHID1; // Enable channel 1
}
开发者ID:NissankaW,项目名称:Mariokart3,代码行数:54,代码来源:actuator_driver.c


示例20: ConfigureButtons

/**
 * @brief Configures the buttons to generate interrupts when pressed.
 */
void ConfigureButtons(void)
{
    // Configure PIO
    PIO_Configure(&pinPB1, 1);
    PIO_Configure(&pinPB2, 1);

    // Initialize interrupts
    PIO_InitializeInterrupts(AT91C_AIC_PRIOR_LOWEST);
    PIO_ConfigureIt(&pinPB1, (void (*)(const Pin *)) ISR_Bp1);
    PIO_ConfigureIt(&pinPB2, (void (*)(const Pin *)) ISR_Bp2);
    PIO_EnableIt(&pinPB1);
    PIO_EnableIt(&pinPB2);
}
开发者ID:mknapik,项目名称:avr-MAC,代码行数:16,代码来源:main.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PIO_Get函数代码示例发布时间:2022-05-30
下一篇:
C++ PIO_Clear函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap