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

C++ rcc_peripheral_enable_clock函数代码示例

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

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



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

示例1: PWR_Init

void PWR_Init(void)
{
    SCB_VTOR = VECTOR_TABLE_LOCATION;
    SCB_SCR  &= ~SCB_SCR_SLEEPONEXIT; //sleep immediate on WFI
    rcc_clock_setup_in_hse_8mhz_out_72mhz();

    /* Enable GPIOA and GPIOE so we can blink LEDs! */
    rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
    rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPEEN);

    /* Disable SWD - SWDIO PA13 is used for Green LED */
    AFIO_MAPR = (AFIO_MAPR & ~AFIO_MAPR_SWJ_MASK) | AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_OFF;

    /* Green LED - pin PA13 */
    gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
                  GPIO_CNF_OUTPUT_PUSHPULL, GPIO13);

    /* Pin to ground - LED lit */
    gpio_clear(GPIOA, GPIO13);

    /* Red LED - pin PE1 */
    gpio_set_mode(GPIOE, GPIO_MODE_OUTPUT_50_MHZ,
                  GPIO_CNF_OUTPUT_PUSHPULL, GPIO1);

    /* Pin to Vcc - LED down */
    gpio_set(GPIOE, GPIO1);
}
开发者ID:PhracturedBlue,项目名称:deviation,代码行数:27,代码来源:at9_power.c


示例2: can_setup

void can_setup(void)
{
	/* Enable peripheral clocks. */
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
	rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_CANEN);

	AFIO_MAPR = AFIO_MAPR_CAN1_REMAP_PORTB;

	/* Configure CAN pin: RX (input pull-up). */
	gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
		      GPIO_CNF_INPUT_PULL_UPDOWN, GPIO_CAN1_PB_RX);
	gpio_set(GPIOB, GPIO_CAN1_PB_RX);

	/* Configure CAN pin: TX. */
	gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
		      GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_CAN1_PB_TX);

	/* NVIC setup. */
	nvic_enable_irq(NVIC_USB_LP_CAN_RX0_IRQ);
	nvic_set_priority(NVIC_USB_LP_CAN_RX0_IRQ, 1);

	/* Reset CAN. */
	can_reset(CAN1);

	/* CAN cell init. */
	if (can_init(CAN1,
		     false,           /* TTCM: Time triggered comm mode? */
		     true,            /* ABOM: Automatic bus-off management? */
		     false,           /* AWUM: Automatic wakeup mode? */
		     false,           /* NART: No automatic retransmission? */
		     false,           /* RFLM: Receive FIFO locked mode? */
		     false,           /* TXFP: Transmit FIFO priority? */
		     CAN_BTR_SJW_1TQ,
		     CAN_BTR_TS1_3TQ,
		     CAN_BTR_TS2_4TQ,
		     12))             /* BRP+1: Baud rate prescaler */
	{
		gpio_set(GPIOA, GPIO8);		/* LED0 off */
		gpio_set(GPIOB, GPIO4);		/* LED1 off */
		gpio_set(GPIOC, GPIO15);       	/* LED2 off */
		gpio_clear(GPIOC, GPIO2);       /* LED3 on */
		gpio_set(GPIOC, GPIO5);	        /* LED4 off */

		/* Die because we failed to initialize. */
		while (1)
			__asm__("nop");
	}

	/* CAN filter 0 init. */
	can_filter_id_mask_32bit_init(CAN1,
				0,     /* Filter ID */
				0,     /* CAN ID */
				0,     /* CAN ID mask */
				0,     /* FIFO assignment (here: FIFO0) */
				true); /* Enable the filter. */

	/* Enable CAN RX interrupt. */
	can_enable_irq(CAN1, CAN_IER_FMPIE0);
}
开发者ID:henryeherman,项目名称:libopencm3,代码行数:60,代码来源:can.c


示例3: gpio_setup

static void gpio_setup(void)
{
	/* Enable GPIOA clock. */
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);

	/* Enable GPIOB clock. */
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);

	gpio_set(GPIOA, GPIO6); /* LED0 off */
	gpio_set(GPIOA, GPIO7); /* LED1 off */
	gpio_set(GPIOB, GPIO0); /* LED2 off */
	gpio_set(GPIOB, GPIO1); /* LED3 off */

	/* Set GPIO6/7 (in GPIO port A) to 'output push-pull' for the LEDs. */
	gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
		      GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);
	gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
		      GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
	
	/* Set GPIO0/1 (in GPIO port B) to 'output push-pull' for the LEDs. */
	gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
		      GPIO_CNF_OUTPUT_PUSHPULL, GPIO0);
	gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
		      GPIO_CNF_OUTPUT_PUSHPULL, GPIO1);
}
开发者ID:balshetzer,项目名称:libopencm3-examples,代码行数:25,代码来源:systick.c


示例4: adc_setup

void adc_setup(void) {
	//ADC
	rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_ADC12EN);
	rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_IOPAEN);
	//ADC
	gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0);
	gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);
	adc_off(ADC1);
	adc_set_clk_prescale(ADC_CCR_CKMODE_DIV2);
        adc_set_single_conversion_mode(ADC1);
        adc_disable_external_trigger_regular(ADC1);
        adc_set_right_aligned(ADC1);
        /* We want to read the temperature sensor, so we have to enable it. */
        adc_enable_temperature_sensor();
        adc_set_sample_time_on_all_channels(ADC1, ADC_SMPR1_SMP_61DOT5CYC);
	uint8_t channel_array[16];
	channel_array[0]=16; // Vts (Internal temperature sensor
	channel_array[0]=1; //ADC1_IN1 (PA0)
	adc_set_regular_sequence(ADC1, 1, channel_array);
	adc_set_resolution(ADC1, ADC_CFGR_RES_12_BIT);
        adc_power_on(ADC1);

        /* Wait for ADC starting up. */
	int i;
        for (i = 0; i < 800000; i++)    /* Wait a bit. */
                __asm__("nop");

}
开发者ID:balshetzer,项目名称:libopencm3-examples,代码行数:28,代码来源:adc.c


示例5: board_init

static void
board_init(void)
{
	/* fix up the max firmware size, we have to read memory to get this */
	board_info.fw_size = APP_SIZE_MAX,

#ifdef INTERFACE_USB
	/* enable GPIO9 with a pulldown to sniff VBUS */
	rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
	gpio_mode_setup(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLDOWN, GPIO9);
#endif

	/* initialise LEDs */
	rcc_peripheral_enable_clock(&RCC_AHB1ENR, BOARD_CLOCK_LEDS);
	gpio_mode_setup(
		BOARD_PORT_LEDS,
		GPIO_MODE_OUTPUT,
		GPIO_PUPD_NONE,
		BOARD_PIN_LED_BOOTLOADER | BOARD_PIN_LED_ACTIVITY);
	gpio_set_output_options(
		BOARD_PORT_LEDS,
		GPIO_OTYPE_PP,
		GPIO_OSPEED_2MHZ,
		BOARD_PIN_LED_BOOTLOADER | BOARD_PIN_LED_ACTIVITY);
	BOARD_LED_ON (
		BOARD_PORT_LEDS,
		BOARD_PIN_LED_BOOTLOADER | BOARD_PIN_LED_ACTIVITY);

	/* enable the power controller clock */
	rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_PWREN);

}
开发者ID:fcayci,项目名称:px4bootloader,代码行数:32,代码来源:main_f4.c


示例6: CHAN_Init

void CHAN_Init()
{
    rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
    rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
    rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
    ADC_Init();

    /* configure channels for analog */
    gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO0);
    gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO1);
    gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO2);
    gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO3);
    gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO4);
    gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO5);
    gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO6);
    /* Enable Voltage measurement */
    gpio_set_mode(GPIOB, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO0);
    gpio_set_mode(GPIOB, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO1);

    /* configure switches for digital I/O */
    gpio_set_mode(GPIOC, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN,
                   GPIO0 | GPIO1 | GPIO2 | GPIO3 | GPIO4 |
                   GPIO5 | GPIO6 | GPIO7 | GPIO8 | GPIO9);
    gpio_set(GPIOC,
                   GPIO0 | GPIO1 | GPIO2 | GPIO3 | GPIO4 |
                   GPIO5 | GPIO6 | GPIO7 | GPIO8 | GPIO9);
    gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO8);
    gpio_set(GPIOA, GPIO8);
}
开发者ID:Chen-Leon,项目名称:DeviationX,代码行数:29,代码来源:channels.c


示例7: adc_init

//*******************************  Para medir la tensión en los pines **********************************
void adc_init (void)
{
  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_ADC1EN);
  rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
  rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN);



  gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);	//PA1   joint_1
  gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO2);	//PA2   joint_2
  gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO3);	//PA3   joint_3
  gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1);	//PC1   joint_4
  gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO2);	//PC2   joint_5
  gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO5);	//PC5   joint_6

  adc_set_clk_prescale(ADC_CCR_ADCPRE_BY2);
  adc_disable_scan_mode(ADC1);
  adc_set_single_conversion_mode(ADC1);

  adc_set_sample_time(ADC1, ADC_CHANNEL1, ADC_SMPR_SMP_3CYC);   //joint_1
  adc_set_sample_time(ADC1, ADC_CHANNEL2, ADC_SMPR_SMP_3CYC);   //joint_2
  adc_set_sample_time(ADC1, ADC_CHANNEL3, ADC_SMPR_SMP_3CYC);   //joint_3
  adc_set_sample_time(ADC1, ADC_CHANNEL11, ADC_SMPR_SMP_3CYC);  //joint_4
  adc_set_sample_time(ADC1, ADC_CHANNEL12, ADC_SMPR_SMP_3CYC);  //joint_5
  adc_set_sample_time(ADC1, ADC_CHANNEL15, ADC_SMPR_SMP_3CYC);  //joint_6

  adc_set_multi_mode(ADC_CCR_MULTI_INDEPENDENT);
  adc_power_on(ADC1);

  //nvic_enable_irq(NVIC_ADC_IRQ);
  //adc_enable_eoc_interrupt(ADC1);
  //adc_disable_eoc_interrupt(ADC1);
}
开发者ID:juan199,项目名称:Microcontroladores_labos,代码行数:34,代码来源:glove.c


示例8: stm32_sdio_rcc_init

/*
 * Set up the GPIO pins and peripheral clocks for the SDIO
 * system. The code should probably take an option card detect
 * pin, at the moment it uses the one used by the Embest board.
 */
static void stm32_sdio_rcc_init(void)
{
    /* Enable clocks for SDIO and DMA2 */
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_SDIOEN);

#ifdef WITH_DMA2
    rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_DMA2EN);
#endif


    /* Setup GPIO Pins for SDIO:
        PC8 - PC11 - DAT0 thru DAT3
              PC12 - CLK
               PD2 - CMD
    */
	gpio_set_output_options(GPIOC, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, GPIO12 );                          // All SDIO lines are push-pull, 25Mhz
	gpio_set_output_options(GPIOC, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, GPIO8 | GPIO9 | GPIO10 | GPIO11 ); // All SDIO lines are push-pull, 25Mhz
	gpio_mode_setup(GPIOC, GPIO_MODE_AF, GPIO_PUPD_PULLUP, GPIO8 | GPIO9 | GPIO10 | GPIO11);            // D0 - D3 enable pullups (bi-directional)
	gpio_mode_setup(GPIOC, GPIO_MODE_AF, GPIO_PUPD_NONE,  GPIO12);                                      // CLK line no pullup
	gpio_set_af(GPIOC, GPIO_AF12, GPIO8 | GPIO9 | GPIO10 | GPIO11 | GPIO12);

	gpio_set_output_options(GPIOD, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, GPIO2);
	gpio_mode_setup(GPIOD, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO12 | GPIO15);
	gpio_mode_setup(GPIOD, GPIO_MODE_AF, GPIO_PUPD_PULLUP, GPIO2);
    gpio_set_af(GPIOD, GPIO_AF12, GPIO2);

#ifdef SDIO_HAS_CARD_DETECT
    /* SDIO Card Detect pin on the Embest Baseboard */
    /*     PB15 as a hacked Card Detect (active LOW for card present) */
    gpio_mode_setup(GPIOB, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, GPIO15);
#endif
}
开发者ID:insane-adding-machines,项目名称:frosted,代码行数:37,代码来源:stm32f446nucleo.c


示例9: KeyInit

void KeyInit(void)
{
	/* Enable AFIO */
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);
	
	/* Remap GPIO_Remap_SWJ_JTAGDisable */
	AFIO_MAPR |= AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON;
	
	/* Enable GPIOB & GPIOE */
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
	
	// PortB 5 6 7 8 开漏输出
	gpio_set_mode(KEY_COL_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO5 | GPIO6 | GPIO7 | GPIO8);
	gpio_set(KEY_COL_PORT, GPIO5 | GPIO6| GPIO7 | GPIO8);
	
	// PortC 6 7 8 9 上拉输入
	gpio_set_mode(KEY_ROW_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO6 | GPIO7 | GPIO8 | GPIO9);
	gpio_set(KEY_ROW_PORT, GPIO6 | GPIO7 | GPIO8 | GPIO9);
	
	//PortC 10 11上拉输入 HOLD FMOD
	gpio_set_mode(KEY_SW_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO10 | GPIO11);
	gpio_set(KEY_SW_PORT, GPIO10 | GPIO11);
	
	KeyFlush();
	KeyStat=KeyScanOnce();//为开机检测按键取得按键状态
}
开发者ID:caoqing32,项目名称:galee-devo7e,代码行数:27,代码来源:FKey.c


示例10: adc_init_rcc

/* Configure and enable RCC for peripherals (ADC1, ADC2, Timer) */
static inline void adc_init_rcc( void )
{
#if defined (USE_AD1) || defined (USE_AD2)
  uint32_t timer;
  volatile uint32_t *rcc_apbenr;
  uint32_t rcc_apb;
#if defined(USE_AD_TIM4)
  timer   = TIM4;
  rcc_apbenr = &RCC_APB1ENR;
  rcc_apb = RCC_APB1ENR_TIM4EN;
#elif defined(USE_AD_TIM1)
  timer   = TIM1;
  rcc_apbenr = &RCC_APB2ENR;
  rcc_apb = RCC_APB2ENR_TIM1EN;
#else
  timer   = TIM2;
  rcc_apbenr = &RCC_APB1ENR;
  rcc_apb = RCC_APB1ENR_TIM2EN;
#endif

  /*
   * Historic Note:
   * Previously in libstm32 we were setting the ADC clock here.
   * It was being set to PCLK2 DIV2 resulting in 36MHz clock on the ADC. I am
   * pretty sure that this is wrong as based on the datasheet the ADC clock
   * must not exceed 14MHz! Now the clock is being set by the clock init
   * routine in libopencm3 so we don't have to set up this clock ourselves any
   * more. This comment is here just as a reminder and may be removed in the
   * future when we know that everything is working properly.
   * (by Esden the historian :D)
   */

  /* Timer peripheral clock enable. */
  rcc_peripheral_enable_clock(rcc_apbenr, rcc_apb);
  /* GPIO peripheral clock enable. */
  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN |
                              RCC_APB2ENR_IOPCEN);

  /* Enable ADC peripheral clocks. */
#ifdef USE_AD1
  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_ADC1EN);
#endif
#ifdef USE_AD2
  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_ADC2EN);
#endif

  /* Time Base configuration */
  timer_reset(timer);
  timer_set_mode(timer, TIM_CR1_CKD_CK_INT,
                 TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP);
  timer_set_period(timer, 0xFF);
  timer_set_prescaler(timer, 0x8);
  timer_set_clock_division(timer, 0x0);
  /* Generate TRGO on every update. */
  timer_set_master_mode(timer, TIM_CR2_MMS_UPDATE);
  timer_enable_counter(timer);

#endif // defined (USE_AD1) || defined (USE_AD2)
}
开发者ID:evanov100,项目名称:paparazzi,代码行数:60,代码来源:adc_arch.c


示例11: clock_setup

static void clock_setup(void)
{
    /* Enable clocks on all the peripherals we are going to use. */
    rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_SPI2EN);
    rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_USART1EN);
    rcc_peripheral_enable_clock(&RCC_AHB1ENR,
                                RCC_AHB1ENR_IOPCEN | RCC_AHB1ENR_IOPAEN | RCC_AHB1ENR_IOPBEN);
}
开发者ID:paulfertser,项目名称:libopencm3-examples,代码行数:8,代码来源:spi_test.c


示例12: lcdInit

void lcdInit() {
  int i;
  // hardware layout specific optimisations here
  // if you change the pinout these need to be changed
  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN | RCC_APB2ENR_AFIOEN);
  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
  
  // timer 2 for backlight dimming
  rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_TIM2EN);
  
  gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_10_MHZ,
                GPIO_CNF_OUTPUT_PUSHPULL, 
                LCD_RST_PIN | LCD_E_PIN | LCD_RW_PIN | LCD_CS_PIN);
  gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_10_MHZ,
                GPIO_CNF_OUTPUT_PUSHPULL,
                LCD_DC_PIN);
  gpio_set_mode(LCD_BL_PORT, GPIO_MODE_OUTPUT_50_MHZ,
                GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, LCD_BL_PIN);
  
  gpio_clear(LCD_RST_PORT, LCD_RST_PIN);
  gpio_set(LCD_CS_PORT, LCD_CS_PIN);
  gpio_set(LCD_DC_PORT, LCD_DC_PIN);
  gpio_clear(LCD_RW_PORT, LCD_RW_PIN);
  gpio_clear(LCD_E_PORT, LCD_E_PIN);
  
  /* === Setup PWM peripherals for brightness === */
   /* global settings for timer 1 */
  TIM2_CR1 = TIM_CR1_CKD_CK_INT | TIM_CR1_CMS_EDGE;
  TIM2_ARR = 65535;
  TIM2_PSC = 0;
  TIM2_EGR = TIM_EGR_UG;

   /* timer 1 channel 2 (screen brightness) */
  TIM2_CCMR2 |= TIM_CCMR2_OC3M_PWM1 | TIM_CCMR2_OC3PE;
  TIM2_CCER |= TIM_CCER_CC3E;
  TIM2_CCR3 = 0;

  TIM2_CR1 |= TIM_CR1_ARPE;
  TIM2_CR1 |= TIM_CR1_CEN;

//   TIM2_BDTR |= TIM_BDTR_MOE;
  
  for(i=0;i<10000;i++) {__asm__("nop\n\t");}
  
  gpio_set(LCD_RST_PORT, LCD_RST_PIN);
  
  for(i=0;i<10000;i++) {__asm__("nop\n\t");}
  
  lcdCommand(LCD_BIAS_SEVENTH);
  lcdCommand(LCD_DIRECTION_FWD);
  lcdCommand(LCD_COMMON_FWD);
  lcdCommand(LCD_VREG_SET);
  lcdCommand(LCD_CONTRAST_HI);
  lcdCommand(LCD_CONTRAST_LO(32));
  lcdCommand(LCD_POWER_SETUP);
  lcdCommand(LCD_DISPLAY_ON);
  
}
开发者ID:hairymnstr,项目名称:oggbox,代码行数:58,代码来源:lcd.c


示例13: platform_init

int platform_init(void)
{
	rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);

	/* Enable peripherals */
	rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_OTGFSEN);
	rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
	rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPBEN);
	rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN);

        /* Fix all flaoting pins*/
	gpio_mode_setup(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLDOWN,
                        0x1ff);

	gpio_mode_setup(GPIOB, GPIO_MODE_INPUT, GPIO_PUPD_PULLDOWN,
                        0xffe2);

	gpio_mode_setup(GPIOC, GPIO_MODE_INPUT, GPIO_PUPD_PULLDOWN,
                        0xf3ff);

	/* Set up USB Pins and alternate function*/
	gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE,
		GPIO9 | GPIO10| GPIO11 | GPIO12);
	gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO10| GPIO11 | GPIO12);

        /* Set TMS/TCK/TDI to high speed*/
        GPIOA_OSPEEDR &=~0xfc00;
        GPIOA_OSPEEDR |= 0xa800;
	gpio_mode_setup(JTAG_PORT, GPIO_MODE_OUTPUT,
			GPIO_PUPD_NONE,
			TMS_PIN | TCK_PIN | TDI_PIN);

	gpio_mode_setup(TDO_PORT, GPIO_MODE_INPUT,
			GPIO_PUPD_NONE,
			TDO_PIN | TRST_PIN);

	gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT,
			GPIO_PUPD_NONE,
			LED_UART );

	/* Setup heartbeat timer */
	systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
	systick_set_reload(168000000/(10*8));	/* Interrupt us at 10 Hz */
	SCB_SHPR(11) &= ~((15 << 4) & 0xff);
	SCB_SHPR(11) |= ((14 << 4) & 0xff);
	systick_interrupt_enable();
	systick_counter_enable();

	usbuart_init();

	SCB_VTOR = 0x10000;	// Relocate interrupt vector table here

	cdcacm_init();

	jtag_scan(NULL);

	return 0;
}
开发者ID:entropia,项目名称:blackmagic,代码行数:58,代码来源:platform.c


示例14: ppm_arch_init

void ppm_arch_init ( void ) {

  /* timer clock enable */
  rcc_peripheral_enable_clock(PPM_RCC, PPM_PERIPHERAL);

  /* GPIOA clock enable */
  rcc_peripheral_enable_clock(&RCC_APB2ENR, PPM_GPIO_PERIPHERAL);

  /* timer gpio configuration */
  gpio_set_mode(PPM_GPIO_PORT, GPIO_MODE_INPUT,
		GPIO_CNF_INPUT_FLOAT, PPM_GPIO_PIN);

  /* Time Base configuration */
  timer_reset(PPM_TIMER);
  timer_set_mode(PPM_TIMER, TIM_CR1_CKD_CK_INT,
		 TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP);
  timer_set_period(PPM_TIMER, 0xFFFF);
  /* run ppm timer at cpu freq / 9 = 8MHz */
  timer_set_prescaler(PPM_TIMER, 8);

 /* TIM configuration: Input Capture mode ---------------------
     The Rising edge is used as active edge,
     Intput pin is either PA1 or PA10
  ------------------------------------------------------------ */
#if defined PPM_PULSE_TYPE && PPM_PULSE_TYPE == PPM_PULSE_TYPE_POSITIVE
  timer_ic_set_polarity(PPM_TIMER, PPM_CHANNEL, TIM_IC_RISING);
#elif defined PPM_PULSE_TYPE && PPM_PULSE_TYPE == PPM_PULSE_TYPE_NEGATIVE
  timer_ic_set_polarity(PPM_TIMER, PPM_CHANNEL, TIM_IC_FALLING);
#else
#error "Unknown PM_PULSE_TYPE"
#endif
  timer_ic_set_input(PPM_TIMER, PPM_CHANNEL, PPM_TIMER_INPUT);
  timer_ic_set_prescaler(PPM_TIMER, PPM_CHANNEL, TIM_IC_PSC_OFF);
  timer_ic_set_filter(PPM_TIMER, PPM_CHANNEL, TIM_IC_OFF);

  /* Enable timer Interrupt(s). */
  nvic_set_priority(PPM_IRQ, 2);
  nvic_enable_irq(PPM_IRQ);

#ifdef PPM_IRQ2
  nvic_set_priority(PPM_IRQ2, 2);
  nvic_enable_irq(PPM_IRQ2);
#endif

  /* Enable the CC2 and Update interrupt requests. */
  timer_enable_irq(PPM_TIMER, PPM_IRQ_FLAGS);

  /* Enable capture channel. */
  timer_ic_enable(PPM_TIMER, PPM_CHANNEL);

  /* TIM enable counter */
  timer_enable_counter(PPM_TIMER);

  ppm_last_pulse_time = 0;
  ppm_cur_pulse = RADIO_CONTROL_NB_CHANNEL;
  timer_rollover_cnt = 0;

}
开发者ID:jornanke,项目名称:paparazzi,代码行数:58,代码来源:ppm_arch.c


示例15: init_codec

void init_codec() {
  /* enable clock for Aux power and power up the regulators */
  rcc_peripheral_enable_clock(&CODEC_PWR_APB, CODEC_RCC_PWR);
  gpio_set_mode(CODEC_PWR_PORT, GPIO_MODE_OUTPUT_50_MHZ,
                GPIO_CNF_OUTPUT_PUSHPULL, CODEC_PWR);
  gpio_set(CODEC_PWR_PORT, CODEC_PWR);
  
  /* enable SPI1 clock */
  rcc_peripheral_enable_clock(&CODEC_SPI_APB, CODEC_RCC_SPI);
  /* enable clock for the chip select pin */
  rcc_peripheral_enable_clock(&CODEC_IOS_APB, CODEC_RCC_IOS);
  /* enable clock for the RST/DREQ lines */
  rcc_peripheral_enable_clock(&CODEC_IOI_APB, CODEC_RCC_IOI);
  
  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);

  /* set the pin modes for the SPI pins */
  gpio_set_mode(CODEC_PORT, GPIO_MODE_OUTPUT_50_MHZ,
                GPIO_CNF_OUTPUT_PUSHPULL, CODEC_CS);
  gpio_set_mode(CODEC_PORT, GPIO_MODE_OUTPUT_50_MHZ,
                GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, CODEC_MOSI);
  gpio_set_mode(CODEC_PORT, GPIO_MODE_OUTPUT_50_MHZ,
                GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, CODEC_SCK);
  gpio_set_mode(CODEC_PORT, GPIO_MODE_INPUT,
                GPIO_CNF_INPUT_FLOAT, CODEC_MISO);

  /* set the modes for the reset and busy pins */
  gpio_set_mode(CODEC_RST_PORT, GPIO_MODE_OUTPUT_50_MHZ,
                GPIO_CNF_OUTPUT_PUSHPULL, CODEC_RST);
  gpio_set_mode(CODEC_DREQ_PORT, GPIO_MODE_INPUT,
                GPIO_CNF_INPUT_FLOAT, CODEC_DREQ);

  gpio_clear(CODEC_RST_PORT, CODEC_RST);

  /* configure the SPI port */
  spi_set_unidirectional_mode(CODEC_SPI);
  spi_disable_crc(CODEC_SPI);
  spi_set_dff_8bit(CODEC_SPI);
  spi_set_full_duplex_mode(CODEC_SPI);
  spi_enable_software_slave_management(CODEC_SPI);
  spi_set_nss_high(CODEC_SPI);
  spi_set_baudrate_prescaler(CODEC_SPI, SPI_CR1_BR_FPCLK_DIV_32);
  spi_set_master_mode(CODEC_SPI);
  spi_send_msb_first(CODEC_SPI);
  spi_set_clock_polarity_0(CODEC_SPI);
  spi_set_clock_phase_0(CODEC_SPI);
  spi_disable_ss_output(CODEC_SPI);
  spi_enable(CODEC_SPI);

  /* disable chip select */
  gpio_set(CODEC_PORT, CODEC_CS);

  /* make sure reset is not asserted */
  gpio_set(CODEC_RST_PORT, CODEC_RST);

  return;
}
开发者ID:mitlab,项目名称:oggbox,代码行数:57,代码来源:vs1053.c


示例16: init

void init(void) {
	rcc_clock_setup_in_hse_8mhz_out_24mhz();

	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
	rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
	led_init();
	output_init();
}
开发者ID:srobo,项目名称:motor-v4-fw,代码行数:9,代码来源:test.c


示例17: clock_setup

static void clock_setup(void)
{
	/* Enable GPIOD clock for LED & USARTs. */
	rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
	rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);

	/* Enable clocks for USART2. */
	rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
}
开发者ID:CNCBASHER,项目名称:libopencm3,代码行数:9,代码来源:usart_irq.c


示例18: clock_setup

/* Set STM32 to 72 MHz. */
void clock_setup(void)
{
    rcc_clock_setup_in_hse_12mhz_out_72mhz();

    /* Enable GPIOC clock. */
    rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
    rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
    rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN);

}
开发者ID:henryhallam,项目名称:libopenstm32,代码行数:11,代码来源:fancyblink.c


示例19: clock_setup

static void clock_setup(void)
{
	/* We are running on MSI after boot. */
	/* Enable GPIOD clock for LED & USARTs. */
	rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_GPIOAEN);
	rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_GPIOBEN);

	/* Enable clocks for USART2. */
	rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USART2EN);
}
开发者ID:SnoreCopter,项目名称:libopencm3-examples,代码行数:10,代码来源:usart.c


示例20: rcc_setup

static void rcc_setup(void)
{
	rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_120MHZ]);

	/* Enable GPIOD clock for onboard leds. */
	rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);

	/* Enable rng clock */
	rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_RNGEN);
}
开发者ID:balshetzer,项目名称:libopencm3-examples,代码行数:10,代码来源:random.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ rcc_set_hpre函数代码示例发布时间:2022-05-30
下一篇:
C++ rcc_periph_clock_enable函数代码示例发布时间: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