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

C++ pin_function函数代码示例

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

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



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

示例1: spi_free

void spi_free(spi_t *obj) {
    // Reset SPI and disable clock
    if (obj->spi == SPI_1) {
        RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE);
        RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE);
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, DISABLE);
    }

    if (obj->spi == SPI_2) {
        RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE);
        RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE);
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, DISABLE);
    }
	 if (obj->spi == SPI_3) {
        RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE);
        RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, DISABLE);
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, DISABLE);
    }

    // Configure GPIOs
    pin_function(obj->pin_miso, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0));
    pin_function(obj->pin_mosi, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0));
    pin_function(obj->pin_sclk, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0));
    pin_function(obj->pin_ssel, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0));
}
开发者ID:52osworld,项目名称:Stm32f103_mbed,代码行数:25,代码来源:spi_api.c


示例2: spi_format

/** Configure the SPI format
 *
 * Set the number of bits per frame, configure clock polarity and phase, shift order and master/slave mode.
 * The default bit order is MSB.
 * @param[in,out] obj   The SPI object to configure
 * @param[in]     bits  The number of bits per frame
 * @param[in]     mode  The SPI mode (clock polarity, phase, and shift direction)
 * @param[in]     slave Zero for master mode or non-zero for slave mode
 */
void spi_format(spi_t *obj, int bits, int mode, int slave)
{
    struct spi_s *spiobj = SPI_S(obj);

    spiobj->spi_struct.frame_size = (bits == 16) ? SPI_FRAMESIZE_16BIT : SPI_FRAMESIZE_8BIT;
    /* Config polarity and phase of SPI */
    switch (mode) {
        case 0:
            spiobj->spi_struct.clock_polarity_phase =  SPI_CK_PL_LOW_PH_1EDGE;
            break;
        case 1:
            spiobj->spi_struct.clock_polarity_phase =  SPI_CK_PL_LOW_PH_2EDGE;
            break;
        case 2:
            spiobj->spi_struct.clock_polarity_phase =  SPI_CK_PL_HIGH_PH_1EDGE;
            break;
        default:
            spiobj->spi_struct.clock_polarity_phase =  SPI_CK_PL_HIGH_PH_2EDGE;

            break;
    }

    if (spiobj->spi_struct.nss != SPI_NSS_SOFT) {
        if (slave) {
            pin_function(spiobj->pin_mosi, MODE_IN_FLOATING);
            pin_function(spiobj->pin_sclk, MODE_IN_FLOATING);
            pin_function(spiobj->pin_ssel, MODE_IN_FLOATING);
            spi_nss_output_disable(spiobj->spi);
        }
    }
    /* Select SPI as master or slave */
    spiobj->spi_struct.device_mode = (slave) ? SPI_SLAVE : SPI_MASTER;

    dev_spi_struct_init(obj);
}
开发者ID:pan-,项目名称:mbed,代码行数:44,代码来源:spi_api.c


示例3: serial_free

void serial_free(serial_t *obj)
{
    // Reset UART and disable clock
    if (obj->uart == UART_1) {
        __USART1_FORCE_RESET();
        __USART1_RELEASE_RESET();
        __USART1_CLK_DISABLE();
    }
    if (obj->uart == UART_2) {
        __USART2_FORCE_RESET();
        __USART2_RELEASE_RESET();
        __USART2_CLK_DISABLE();
    }
    if (obj->uart == UART_3) {
        __USART3_FORCE_RESET();
        __USART3_RELEASE_RESET();
        __USART3_CLK_DISABLE();
    }

    // Configure GPIOs
    pin_function(obj->pin_tx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
    pin_function(obj->pin_rx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));

    serial_irq_ids[obj->index] = 0;
}
开发者ID:vinnierabbit,项目名称:mbed,代码行数:25,代码来源:serial_api.c


示例4: spi_free

/** Release a SPI object
 *
 * TODO: spi_free is currently unimplemented
 * This will require reference counting at the C++ level to be safe
 *
 * Return the pins owned by the SPI object to their reset state
 * Disable the SPI peripheral
 * Disable the SPI clock
 * @param[in] obj The SPI object to deinitialize
 */
void spi_free(spi_t *obj)
{
    struct spi_s *spiobj = SPI_S(obj);
    spi_disable(spiobj->spi);

    /* Disable and deinit SPI */
    if (spiobj->spi == SPI0) {
        spi_i2s_deinit(SPI0);
        rcu_periph_clock_disable(RCU_SPI0);
    }
    if (spiobj->spi == SPI1) {
        spi_i2s_deinit(SPI1);
        rcu_periph_clock_disable(RCU_SPI1);
    }
    if (spiobj->spi == SPI2) {
        spi_i2s_deinit(SPI2);
        rcu_periph_clock_disable(RCU_SPI2);
    }
    /* Deinit GPIO mode of SPI pins */
    pin_function(spiobj->pin_miso, MODE_IN_FLOATING);
    pin_function(spiobj->pin_mosi, MODE_IN_FLOATING);
    pin_function(spiobj->pin_sclk, MODE_IN_FLOATING);
    if (spiobj->spi_struct.nss != SPI_NSS_SOFT) {
        pin_function(spiobj->pin_ssel, MODE_IN_FLOATING);
    }
}
开发者ID:pan-,项目名称:mbed,代码行数:36,代码来源:spi_api.c


示例5: serial_set_flow_control

void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
{
    /* Sanity check arguments */
    MBED_ASSERT(obj);

    if(FlowControlNone == type) {
        /* Disable Hardware Handshaking. */
        _USART(obj)->US_MR = (_USART(obj)->US_MR & ~US_MR_USART_MODE_Msk) | US_MR_USART_MODE_NORMAL;
        return;
    }

    /*To determine the uart peripheral associated with pins*/
    UARTName uart_cts = (UARTName)pinmap_peripheral(txflow, PinMap_UART_CTS);
    UARTName uart_rts = (UARTName)pinmap_peripheral(rxflow, PinMap_UART_RTS);
    UARTName uart = (UARTName)pinmap_merge(uart_cts, uart_rts);
    MBED_ASSERT(uart != (UARTName)NC);

    if((FlowControlCTS == type) || (FlowControlRTSCTS== type)) {
        /* Configure CTS pin. */
        pin_function(txflow, pinmap_find_function(txflow, PinMap_UART_CTS));
        ioport_disable_pin(txflow);
    }

    if((FlowControlRTS == type) || (FlowControlRTSCTS== type))  {
        /* Configure CTS pin. */
        pin_function(rxflow, pinmap_find_function(rxflow, PinMap_UART_RTS));
        ioport_disable_pin(rxflow);
    }

    /* Set hardware handshaking mode. */
    _USART(obj)->US_MR = (_USART(obj)->US_MR & ~US_MR_USART_MODE_Msk) | US_MR_USART_MODE_HW_HANDSHAKING;
}
开发者ID:DanKupiniak,项目名称:mbed,代码行数:32,代码来源:serial_api.c


示例6: spi_free

void spi_free(spi_t *obj) {
    // Reset SPI and disable clock
    if (obj->spi == SPI_1) {
        __SPI1_FORCE_RESET();
        __SPI1_RELEASE_RESET();
        __SPI1_CLK_DISABLE();
    }

    if (obj->spi == SPI_2) {
        __SPI2_FORCE_RESET();
        __SPI2_RELEASE_RESET();
        __SPI2_CLK_DISABLE();
    }

    if (obj->spi == SPI_3) {
        __SPI3_FORCE_RESET();
        __SPI3_RELEASE_RESET();
        __SPI3_CLK_DISABLE();
    }

    // Configure GPIOs
    pin_function(obj->pin_miso, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
    pin_function(obj->pin_mosi, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
    pin_function(obj->pin_sclk, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
    pin_function(obj->pin_ssel, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
}
开发者ID:allankliu,项目名称:mbed,代码行数:26,代码来源:spi_api.c


示例7: gpio_dir

void gpio_dir(gpio_t *obj, PinDirection direction) {
    if (direction == PIN_OUTPUT) {
        pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_OUT, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF));
    } else { // PIN_INPUT
        pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF));
    }
}
开发者ID:allankliu,项目名称:mbed,代码行数:7,代码来源:gpio_api.c


示例8: spi_init

/** Initialize the SPI peripheral
 *
 * Configures the pins used by SPI, sets a default format and frequency, and enables the peripheral
 * @param[out] obj  The SPI object to initialize
 * @param[in]  mosi The pin to use for MOSI
 * @param[in]  miso The pin to use for MISO
 * @param[in]  sclk The pin to use for SCLK
 */
void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk)
{
	MBED_ASSERT(obj);
	MBED_ASSERT(mosi !=NC && miso!=NC && sclk !=NC );
	
	 if (g_sys_init == 0) {
        sysclk_init();
        system_board_init();
        g_sys_init = 1;
    }
	
	Spi *sercombase = pinmap_find_sercom(mosi,miso,sclk);
	MBED_ASSERT(sercombase!=NC);
	
	pinmap_find_spi_info(sercombase, obj);
	MBED_ASSERT(obj->spi.flexcom!=NC);
	MBED_ASSERT(obj->spi.pdc!=NC);
	
    /* Configure SPI pins */
    pin_function(mosi, pinmap_find_function(mosi, PinMap_SPI_MOSI));
    ioport_disable_pin(mosi);

    pin_function(miso, pinmap_find_function(miso, PinMap_SPI_MISO));
    ioport_disable_pin(miso);

    pin_function(sclk, pinmap_find_function(sclk, PinMap_SPI_SCLK));
    ioport_disable_pin(sclk);
	
	#if (SAMG55)
	/* Enable the peripheral and set SPI mode. */
	flexcom_enable(obj->spi.flexcom);
	flexcom_set_opmode(obj->spi.flexcom, FLEXCOM_SPI);
	#else
	/* Configure an SPI peripheral. */
	spi_enable_clock(sercombase);
	#endif
	spi_disable(sercombase);
	spi_reset(sercombase);
	spi_set_lastxfer(sercombase);
	spi_set_master_mode(sercombase);
	spi_disable_mode_fault_detect(sercombase);
	spi_set_peripheral_chip_select_value(sercombase, SPI_CHIP_SEL);
	spi_set_clock_polarity(sercombase, SPI_CHIP_SEL, SPI_CLK_POLARITY);
	spi_set_clock_phase(sercombase, SPI_CHIP_SEL, SPI_CLK_PHASE);
	spi_set_bits_per_transfer(sercombase, SPI_CHIP_SEL, SPI_CSR_BITS_8_BIT);
	spi_set_baudrate_div(sercombase, SPI_CHIP_SEL,(sysclk_get_cpu_hz() / gSPI_clock));
	spi_set_transfer_delay(sercombase, SPI_CHIP_SEL, SPI_DLYBS,SPI_DLYBCT);
	
	spi_enable(sercombase);

	pdc_disable_transfer(obj->spi.pdc, PERIPH_PTCR_RXTDIS |	PERIPH_PTCR_TXTDIS);

	obj->spi.spi_base=sercombase;
	obj->spi.cs= SPI_CHIP_SEL;
	obj->spi.polarity=SPI_CLK_POLARITY;
	obj->spi.phase=SPI_CLK_PHASE;
	obj->spi.transferrate=SPI_CSR_BITS_8_BIT;
	obj->spi.is_slave=0;
}
开发者ID:ARMmbed,项目名称:mbed-hal-atmel-samcortexm4,代码行数:67,代码来源:spi_api.c


示例9: i2c_init_pins

/*
 * Initializes i/o pins for i2c sda/scl.
 */
static void i2c_init_pins(i2c_obj_t *obj)
{
    /* MBED driver reserves pins for I2C as Ditigal IO while doing I2C error
     * recovery in constructor.
     */
    pin_function(obj->pin_sda, pinmap_function(obj->pin_sda, PinMap_I2C_SDA));
    pin_function(obj->pin_scl, pinmap_function(obj->pin_scl, PinMap_I2C_SCL));
}
开发者ID:donatieng,项目名称:mbed,代码行数:11,代码来源:i2c_api.c


示例10: gpio_dir

void gpio_dir(gpio_t *obj, PinDirection direction) {
    MBED_ASSERT(obj->pin != (PinName)NC);
    if (direction == PIN_OUTPUT) {
        pin_function(obj->pin, STM_PIN_DATA(STM_MODE_OUTPUT_PP, GPIO_NOPULL, 0));
    } else { // PIN_INPUT
        pin_function(obj->pin, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
    }
}
开发者ID:AsamQi,项目名称:mbed,代码行数:8,代码来源:gpio_api.c


示例11: gpio_dir

void gpio_dir(gpio_t *obj, PinDirection direction) {
    if (direction == PIN_OUTPUT) {
        pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_Out_PP, 0));
    }
    else { // PIN_INPUT
        pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0));
    }
}
开发者ID:ElAbbassi,项目名称:mbed,代码行数:8,代码来源:gpio_api.c


示例12: NVIC_DisableIRQ

USBHAL::USBHAL(void) {
    NVIC_DisableIRQ(OTG_FS_IRQn);
    epCallback[0] = &USBHAL::EP1_OUT_callback;
    epCallback[1] = &USBHAL::EP1_IN_callback;
    epCallback[2] = &USBHAL::EP2_OUT_callback;
    epCallback[3] = &USBHAL::EP2_IN_callback;
    epCallback[4] = &USBHAL::EP3_OUT_callback;
    epCallback[5] = &USBHAL::EP3_IN_callback;

    // Enable power and clocking
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;

#if defined(TARGET_STM32F407VG) || defined(TARGET_STM32F401RE) || defined(TARGET_STM32F411RE) || defined(TARGET_STM32F412ZG) || defined(TARGET_STM32F429ZI)
    pin_function(PA_8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
    pin_function(PA_9, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLDOWN, GPIO_AF10_OTG_FS));
    pin_function(PA_10, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS));
    pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
    pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
#else
    pin_function(PA_8, STM_PIN_DATA(2, 10));
    pin_function(PA_9, STM_PIN_DATA(0, 0));
    pin_function(PA_10, STM_PIN_DATA(2, 10));
    pin_function(PA_11, STM_PIN_DATA(2, 10));
    pin_function(PA_12, STM_PIN_DATA(2, 10));

    // Set ID pin to open drain with pull-up resistor
    pin_mode(PA_10, OpenDrain);
    GPIOA->PUPDR &= ~(0x3 << 20);
    GPIOA->PUPDR |= 1 << 20;

    // Set VBUS pin to open drain
    pin_mode(PA_9, OpenDrain);
#endif

    RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN;

    // Enable interrupts
    OTG_FS->GREGS.GAHBCFG |= (1 << 0);

    // Turnaround time to maximum value - too small causes packet loss
    OTG_FS->GREGS.GUSBCFG |= (0xF << 10);

    // Unmask global interrupts
    OTG_FS->GREGS.GINTMSK |= (1 << 3) | // SOF
                             (1 << 4) | // RX FIFO not empty
                             (1 << 12); // USB reset

    OTG_FS->DREGS.DCFG |= (0x3 << 0) | // Full speed
                          (1 << 2); // Non-zero-length status OUT handshake

    OTG_FS->GREGS.GCCFG |= (1 << 19) | // Enable VBUS sensing
                           (1 << 16); // Power Up

    instance = this;
    NVIC_SetVector(OTG_FS_IRQn, (uint32_t)&_usbisr);
    NVIC_SetPriority(OTG_FS_IRQn, 1);
}
开发者ID:Archcady,项目名称:mbed-os,代码行数:57,代码来源:USBHAL_STM32F4.cpp


示例13: serial_init

void serial_init(serial_t *obj, PinName tx, PinName rx) {
    int is_stdio_uart = 0;
    
    // determine the UART to use
    UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
    UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
    UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
    MBED_ASSERT((int)uart != NC);

    obj->uart = (LPC_USART_Type *)uart;
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12);
    
    // [TODO] Consider more elegant approach
    // disconnect USBTX/RX mapping mux, for case when switching ports
#ifdef USBTX
    pin_function(USBTX, 0);
    pin_function(USBRX, 0);
#endif

    // enable fifos and default rx trigger level
    obj->uart->FCR = 1 << 0  // FIFO Enable - 0 = Disables, 1 = Enabled
                   | 0 << 1  // Rx Fifo Reset
                   | 0 << 2  // Tx Fifo Reset
                   | 0 << 6; // Rx irq trigger level - 0 = 1 char, 1 = 4 chars, 2 = 8 chars, 3 = 14 chars
    
    // disable irqs
    obj->uart->IER = 0 << 0  // Rx Data available irq enable
                   | 0 << 1  // Tx Fifo empty irq enable
                   | 0 << 2; // Rx Line Status irq enable
    
    // set default baud rate and format
    serial_baud  (obj, 9600);
    serial_format(obj, 8, ParityNone, 1);
    
    // pinout the chosen uart
    pinmap_pinout(tx, PinMap_UART_TX);
    pinmap_pinout(rx, PinMap_UART_RX);
    
    // set rx/tx pins in PullUp mode
    if (tx != NC) {
        pin_mode(tx, PullUp);
    }
    if (rx != NC) {
        pin_mode(rx, PullUp);
    }
    
    switch (uart) {
        case UART_0: obj->index = 0; break;
    }
    
    is_stdio_uart = (uart == STDIO_UART) ? (1) : (0);
    
    if (is_stdio_uart) {
        stdio_uart_inited = 1;
        memcpy(&stdio_uart, obj, sizeof(serial_t));
    }
}
开发者ID:ademuri,项目名称:arm,代码行数:57,代码来源:serial_api.c


示例14: port_dir

void port_dir(port_t *obj, PinDirection dir) {
    uint32_t i;
    obj->direction = dir;
    for (i = 0; i < 16; i++) { // Process all pins
        if (obj->mask & (1 << i)) { // If the pin is used
            if (dir == PIN_OUTPUT) {
                pin_function(port_pin(obj->port, i), STM_PIN_DATA(GPIO_Mode_OUT, GPIO_OType_PP, GPIO_PuPd_NOPULL, 0xFF));
            } else { // PIN_INPUT
                pin_function(port_pin(obj->port, i), STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF));
            }
        }
    }  
}
开发者ID:23chrischen,项目名称:mbed,代码行数:13,代码来源:port_api.c


示例15: spi_free

void spi_free(spi_t *obj)
{
    // Reset SPI and disable clock
    switch(obj->spi.module) {
        case 0:
            __SPI1_FORCE_RESET();
            __SPI1_RELEASE_RESET();
            __SPI1_CLK_DISABLE();
            break;
        case 1:
            __SPI2_FORCE_RESET();
            __SPI2_RELEASE_RESET();
            __SPI2_CLK_DISABLE();
            break;
        case 2:
            __SPI3_FORCE_RESET();
            __SPI3_RELEASE_RESET();
            __SPI3_CLK_DISABLE();
            break;
#if MODULES_SIZE_SPI > 3
        case 3:
            __SPI4_FORCE_RESET();
            __SPI4_RELEASE_RESET();
            __SPI4_CLK_DISABLE();
            break;
#endif
#if MODULES_SIZE_SPI > 4
        case 4:
            __SPI5_FORCE_RESET();
            __SPI5_RELEASE_RESET();
            __SPI5_CLK_DISABLE();
            break;
#endif
#if MODULES_SIZE_SPI > 5
        case 5:
            __SPI6_FORCE_RESET();
            __SPI6_RELEASE_RESET();
            __SPI6_CLK_DISABLE();
            break;
#endif
        default:
            break;
    }

    // Configure GPIOs
    pin_function(obj->spi.pin_miso, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
    pin_function(obj->spi.pin_mosi, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
    pin_function(obj->spi.pin_sclk, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));

    DEBUG_PRINTF("SPI%u: Free\n", obj->spi.module+1);
}
开发者ID:ARMmbed,项目名称:mbed-hal-st-stm32f4,代码行数:51,代码来源:spi_api.c


示例16: pin_function

int SPIHalfDuplex::write(int value) {
    int t_bits = _bits;
    pin_function(_mosi, SPI_MODE);
    int ret_val = SPI::write(value);
    if (ret_val != value) {
        return -1;
    }
    format(_sbits, _mode);
    pin_function(_mosi, GPIO_MODE);
    ret_val = SPI::write(0x55);
    format(t_bits, _mode);
    pin_function(_mosi, SPI_MODE);
    return ret_val;
}
开发者ID:1deus,项目名称:tmk_keyboard,代码行数:14,代码来源:SPIHalfDuplex.cpp


示例17: serial_free

/** Release the serial peripheral, not currently invoked. It requires further
 *  resource management.
 *
 * @param obj The serial object
 */
void serial_free(serial_t *obj)
{
    struct serial_s *p_obj     = GET_SERIAL_S(obj);
    rcu_periph_enum rcu_periph = usart_clk[p_obj->index];

    /* reset USART and disable clock */
    usart_deinit(p_obj->uart);
    rcu_periph_clock_disable(rcu_periph);

    serial_irq_ids[p_obj->index] = 0;

    /* reset the GPIO state */
    pin_function(p_obj->pin_tx, MODE_IN_FLOATING);
    pin_function(p_obj->pin_rx, MODE_IN_FLOATING);
}
开发者ID:oscarh,项目名称:mbed-os,代码行数:20,代码来源:serial_api.c


示例18: pin_pwm_control

int pin_pwm_control(unsigned char pin, unsigned char duty_cycle)
{
	unsigned char pf = pin_function(pin);
 
	if(pf != PIN_FUNCTION_PWM) { 
		return PIN_STAT_ERR_UNSUPFUNC;
	}

	int port;
	int bit;

	if((port = pin2port(pin)) < 0) return port;
	if((bit  = pin2bit(pin))  < 0) return bit;

	if(port == 1) {
		// e.g. DC=50%: (20000 / 100) * (128 / 2.55) ~ 10000 
		TA0CCR1 = (TA0CCR0 / 100) * (duty_cycle / 2.55); 
	}
	else {
		// e.g. DC=50%: (20000 / 100) * (128 / 2.55) ~ 10000 
		TA1CCR1 = (TA1CCR0 / 100) * (duty_cycle / 2.55); 
	}

	return PIN_STAT_OK;
}
开发者ID:areben,项目名称:ROCKETuC,代码行数:25,代码来源:pin_msp430.c


示例19: gpio_set

uint32_t gpio_set(PinName pin) {  
    if (pin == NC) return 0;

    pin_function(pin, STM_PIN_DATA(GPIO_Mode_IN_FLOATING, 0));

    return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask
}
开发者ID:ElAbbassi,项目名称:mbed,代码行数:7,代码来源:gpio_api.c


示例20: gpio_set

uint32_t gpio_set(PinName pin)
{
    MBED_ASSERT(pin != (PinName)NC);

    pin_function(pin, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
    return (uint32_t)(1 << ((uint32_t)pin & 0xF)); // Return the pin mask
}
开发者ID:Suretronic,项目名称:nz32ultrasonic,代码行数:7,代码来源:gpio_api.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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