本文整理汇总了C++中PIN_FUNC_SELECT函数的典型用法代码示例。如果您正苦于以下问题:C++ PIN_FUNC_SELECT函数的具体用法?C++ PIN_FUNC_SELECT怎么用?C++ PIN_FUNC_SELECT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PIN_FUNC_SELECT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: user_init
// Init function
void ICACHE_FLASH_ATTR user_init()
{
struct station_config station_conf;
// Enable GPIO
gpio_init();
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
gpio_output_set(0, 0, (1<<ELGPIO), 0);
// Set station mode
wifi_set_opmode_current(STATION_MODE);
// Set AP settings
os_memcpy(&station_conf.ssid, SSID, 32);
os_memcpy(&station_conf.password, SSID_PASSWORD, 64);
wifi_station_set_config(&station_conf);
// Set an event handler for WiFi events
wifi_set_event_handler_cb(wifi_callback);
// Setup poll and EL timers, but don't start them yet
os_timer_disarm(&poll_timer);
os_timer_setfn(&poll_timer, poll_timer_callback, NULL);
os_timer_disarm(&el_timer);
os_timer_setfn(&el_timer, el_timer_callback, NULL);
os_printf("user_init() complete!\n\r");
}
示例2: user_spi_pin_init
/*
* 函数:user_spi_pin_init
* 说明:SPI引脚初始化
*/
void ICACHE_FLASH_ATTR
user_spi_pin_init(void)
{
#if defined(HARD_SPI)
SpiAttr hSpiAttr;
hSpiAttr.bitOrder = SpiBitOrder_MSBFirst;
/*
* SpiSpeed_0_5MHz = 160,
* SpiSpeed_1MHz = 80,
* SpiSpeed_2MHz = 40,
* SpiSpeed_5MHz = 16,
* SpiSpeed_8MHz = 10,
* SpiSpeed_10MHz = 8,
*/
hSpiAttr.speed = SpiSpeed_0_5MHz;
hSpiAttr.mode = SpiMode_Master;
hSpiAttr.subMode = SpiSubMode_0;
// Init HSPI GPIO
WRITE_PERI_REG(PERIPHS_IO_MUX, 0x105);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, 2);//configure io to spi mode
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, 2);//configure io to spi mode
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, 2);//configure io to spi mode
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, 2);//configure io to spi mode
SPIInit(SpiNum_HSPI, &hSpiAttr);
#elif defined(SOFT_SPI)
SOFT_PIN_INIT();
#else
#error #error "Please define SPI Interface mode : SOFT_SPI or HARD_SPI"
#endif
}
示例3: some_timer_func
void some_timer_func(void *arg) // in Arduino this is loop the main loop
{
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_U0CTS);//CONFIG MTCK PIN FUNC TO U0CTS
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_U0RTS);//CONFIG MTDO PIN FUNC TO U0RTS
SET_PERI_REG_MASK(0x3ff00028 , BIT2);//SWAP PIN : U0TXD<==>U0RTS(MTDO) , U0RXD<==>U0CTS(MTCK)
os_printf("pins activated");
}
示例4: GPIO_INTER
LOCAL void ICACHE_FLASH_ATTR
GPIO_INTER(void)
{
os_printf(" LVZAINA ===> SmartConfig start! \n");
uint32 gpio_status;
uint8 index = 0;
gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
//clear interrupt status
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14);
while(index < 3)
{
os_printf(" LVZAINA ===> SmartConfig... \n");
gpio_output_set(0, 1<<13, 1<<13, 0);
gpio_output_set(1<<15,0 , 1<<15, 0);
gpio_output_set(0, 1<<14, 1<<14, 0);
gpio_io_wait(500000);
gpio_output_set(0, 1<<15, 1<<15, 0);
gpio_output_set(1<<13,0 , 1<<13, 0);
gpio_output_set(1<<14,0 , 1<<14, 0);
gpio_io_wait(500000);
/*if( is_wificonfig_ok == 1)*/
/*break;*/
index++;
}
}
示例5: i2c_master_gpio_init
/******************************************************************************
* FunctionName : i2c_master_gpio_init
* Description : config SDA and SCL gpio to open-drain output mode,
* mux and gpio num defined in i2c_master.h
* Parameters : uint8 sda and scl pin numbers
* Returns : bool, true if init okay
*******************************************************************************/
bool i2c_master_gpio_init(uint8 sda, uint8 scl)
{
if((sda > GPIO_PIN_NUM) || (pin_func[sda] == GPIO_PIN_FUNC_INVALID)){
return false;
}
if((scl > GPIO_PIN_NUM) || (pin_func[scl] == GPIO_PIN_FUNC_INVALID)){
return false;
}
pinSDA = sda;
pinSCL = scl;
ETS_GPIO_INTR_DISABLE() ;
// ETS_INTR_LOCK();
PIN_FUNC_SELECT(pin_mux[sda], pin_func[sda]);
PIN_FUNC_SELECT(pin_mux[scl], pin_func[scl]);
GPIO_REG_WRITE(GPIO_PIN_ADDR(GPIO_ID_PIN(sda)), GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(sda))) | GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)); //open drain;
GPIO_REG_WRITE(GPIO_ENABLE_ADDRESS, GPIO_REG_READ(GPIO_ENABLE_ADDRESS) | (1 << sda));
GPIO_REG_WRITE(GPIO_PIN_ADDR(GPIO_ID_PIN(scl)), GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(scl))) | GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)); //open drain;
GPIO_REG_WRITE(GPIO_ENABLE_ADDRESS, GPIO_REG_READ(GPIO_ENABLE_ADDRESS) | (1 << scl));
i2c_master_setDC(1, 1);
ETS_GPIO_INTR_ENABLE() ;
// ETS_INTR_UNLOCK();
i2c_master_init();
return true;
}
示例6: dmx_task
void ICACHE_FLASH_ATTR dmx_task(os_event_t *events) {
int i;
if(twinkl_has_changes()) {
INFO("Updating DMX channels\n");
twinkl_render(dmx_channels);
}
//INFO("Sending DMX channels\n");
//Space for break
PIN_FUNC_SELECT(pin_mux[dmx_tx_pin], FUNC_GPIO2);
gpio_output_set(0, BIT2, BIT2, 0);
os_delay_us(125);
//Mark After Break
gpio_output_set(BIT2, 0, BIT2, 0);
os_delay_us(50);
//Looks the wrong way round, but reduces jitter somehow
//Do not touch.
PIN_FUNC_SELECT(pin_mux[dmx_tx_pin], FUNC_U1TXD_BK);
uart_tx_one_char(1, 0);
for(i = 0; i < TWINKL_CHANNEL_COUNT; i++) {
uart_tx_one_char(1, dmx_channels[i]);
}
//INFO("Done sending DMX channels\n");
if(udp_server != NULL) {
os_timer_arm(&dmx_update_timer, dmx_refresh_delay, 0);
}
}
示例7: ioInit
void ioInit() {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
gpio_output_set(0, 0, (1<<LEDGPIO), (1<<BTNGPIO));
os_timer_disarm(&resetBtntimer);
os_timer_setfn(&resetBtntimer, resetBtnTimerCb, NULL);
os_timer_arm(&resetBtntimer, 500, 1);
/*
void gpio_output_set (uint32 set_mask, uint32 clear_mask, uint32 enable_mask,
uint32 disable_mask)
Input parameters:
uint32 disable_mask — settings disable bits,
uint32 enable_mask — settings enable output bit,
uint32 clear_mask — set the output to a low position,
uint32 set_mask — set the output to a high position.
*/
// system_mktime(uint32 year, uint32 mon, uint32 day, uint32 hour, uint32 min, uint32 sec);
// system_mktime(2014, 1,1,0, 0,0);
//uint32 time = system_get_time()/TIMEMILIMIL;
//os_printf("[%d] ioInit().\n",time);
timerCounter=0;
timerCounterOverAll=0; triggerLastTime=0;
}
示例8: pwm_init
/******************************************************************************
* FunctionName : pwm_init
* Description : pwm gpio, params and timer initialization
* Parameters : uint16 freq : pwm freq param
* uint8 *duty : each channel's duty
* Returns : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR
pwm_init(uint16 freq, uint8 *duty)
{
uint8 i;
ETS_FRC_TIMER1_INTR_ATTACH(pwm_tim1_intr_handler, NULL);
TM1_EDGE_INT_ENABLE();
ETS_FRC1_INTR_ENABLE();
RTC_CLR_REG_MASK(FRC1_INT_ADDRESS, FRC1_INT_CLR_MASK);
RTC_REG_WRITE(FRC1_CTRL_ADDRESS, //FRC2_AUTO_RELOAD|
DIVDED_BY_16
| FRC1_ENABLE_TIMER
| TM_EDGE_INT);
RTC_REG_WRITE(FRC1_LOAD_ADDRESS, 0);
PIN_FUNC_SELECT(PWM_0_OUT_IO_MUX, PWM_0_OUT_IO_FUNC);
PIN_FUNC_SELECT(PWM_1_OUT_IO_MUX, PWM_1_OUT_IO_FUNC);
PIN_FUNC_SELECT(PWM_2_OUT_IO_MUX, PWM_2_OUT_IO_FUNC);
for (i = 0; i < PWM_CHANNEL; i++) {
pwm_gpio |= (1 << pwm_out_io_num[i]);
}
pwm_set_freq_duty(freq, duty);
pwm_start();
}
示例9: hspi_init
void hspi_init(void)
{
spi_fifo = (uint32_t*)SPI_FLASH_C0(HSPI);
WRITE_PERI_REG(PERIPHS_IO_MUX, 0x105); //clear bit9
//PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, 2); // HSPIQ MISO GPIO12
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, 2); // HSPID MOSI GPIO13
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, 2); // CLK GPIO14
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, 2); // CS GPIO15
// SPI clock = CPU clock / 10 / 4
// time length HIGHT level = (CPU clock / 10 / 2) ^ -1,
// time length LOW level = (CPU clock / 10 / 2) ^ -1
WRITE_PERI_REG(SPI_FLASH_CLOCK(HSPI),
(((HSPI_PRESCALER - 1) & SPI_CLKDIV_PRE) << SPI_CLKDIV_PRE_S) |
((1 & SPI_CLKCNT_N) << SPI_CLKCNT_N_S) |
((0 & SPI_CLKCNT_H) << SPI_CLKCNT_H_S) |
((1 & SPI_CLKCNT_L) << SPI_CLKCNT_L_S));
WRITE_PERI_REG(SPI_FLASH_CTRL1(HSPI), 0);
uint32_t regvalue = SPI_FLASH_DOUT;
regvalue &= ~(BIT2 | SPI_FLASH_USR_ADDR | SPI_FLASH_USR_DUMMY | SPI_FLASH_USR_DIN | SPI_USR_COMMAND | SPI_DOUTDIN); //clear bit 2 see example IoT_Demo
WRITE_PERI_REG(SPI_FLASH_USER(HSPI), regvalue);
}
示例10: ioInit
void ioInit() {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5);
//PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);
// gpio_output_set(0, 0, (1<<LEDGPIO), (1<<BTNGPIO));
// os_timer_disarm(&resetBtntimer);
// os_timer_setfn(&resetBtntimer, resetBtnTimerCb, NULL);
// os_timer_arm(&resetBtntimer, 500, 1);
light_param.pwm_period = 1000;
uint32 io_info[][3] = { {PWM_0_OUT_IO_MUX,PWM_0_OUT_IO_FUNC,PWM_0_OUT_IO_NUM},
{PWM_1_OUT_IO_MUX,PWM_1_OUT_IO_FUNC,PWM_1_OUT_IO_NUM},
{PWM_2_OUT_IO_MUX,PWM_2_OUT_IO_FUNC,PWM_2_OUT_IO_NUM},
// {PWM_3_OUT_IO_MUX,PWM_3_OUT_IO_FUNC,PWM_3_OUT_IO_NUM},
// {PWM_4_OUT_IO_MUX,PWM_4_OUT_IO_FUNC,PWM_4_OUT_IO_NUM},
};
uint32 pwm_duty_init[PWM_CHANNEL] = {0,0,0};
/*PIN FUNCTION INIT FOR PWM OUTPUT*/
pwm_init(light_param.pwm_period, pwm_duty_init ,PWM_CHANNEL,io_info);
set_pwm_debug_en(0);
pwm_start();
}
示例11: i2c_init
/**
* I2C init function
* This sets up the GPIO io
*/
void ICACHE_FLASH_ATTR
i2c_init(void)
{
//Disable interrupts
ETS_GPIO_INTR_DISABLE();
//Set pin functions
PIN_FUNC_SELECT(I2C_SDA_MUX, I2C_SDA_FUNC);
PIN_FUNC_SELECT(I2C_SCK_MUX, I2C_SCK_FUNC);
//Set SDA as open drain
GPIO_REG_WRITE(
GPIO_PIN_ADDR(GPIO_ID_PIN(I2C_SDA_PIN)),
GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(I2C_SDA_PIN))) |
GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)
);
GPIO_REG_WRITE(GPIO_ENABLE_ADDRESS, GPIO_REG_READ(GPIO_ENABLE_ADDRESS) | (1 << I2C_SDA_PIN));
//Set SCK as open drain
GPIO_REG_WRITE(
GPIO_PIN_ADDR(GPIO_ID_PIN(I2C_SCK_PIN)),
GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(I2C_SCK_PIN))) |
GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)
);
GPIO_REG_WRITE(GPIO_ENABLE_ADDRESS, GPIO_REG_READ(GPIO_ENABLE_ADDRESS) | (1 << I2C_SCK_PIN));
//Turn interrupt back on
ETS_GPIO_INTR_ENABLE();
i2c_sda(1);
i2c_sck(1);
return;
}
示例12: user_link_led_init
LOCAL void ICACHE_FLASH_ATTR
user_link_led_init(void)
{
PIN_FUNC_SELECT(SENSOR_LINK_LED_IO_MUX, SENSOR_LINK_LED_IO_FUNC);
PIN_FUNC_SELECT(SENSOR_UNUSED_LED_IO_MUX, SENSOR_UNUSED_LED_IO_FUNC);
GPIO_OUTPUT_SET(GPIO_ID_PIN(SENSOR_UNUSED_LED_IO_NUM), 0);
}
示例13: i2c_init
void ICACHE_FLASH_ATTR i2c_init(void)
{
// MUX selection
PIN_FUNC_SELECT(SDA_MUX, SDA_FUNC);
PIN_FUNC_SELECT(SCL_MUX, SCL_FUNC);
// Set SDA as OD output
GPIO_REG_WRITE
(
GPIO_PIN_ADDR(GPIO_ID_PIN(SDA_PIN)),
GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(SDA_PIN))) | GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)
);
// Set SCK as OD output
GPIO_REG_WRITE
(
GPIO_PIN_ADDR(GPIO_ID_PIN(SCL_PIN)),
GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(SCL_PIN))) | GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)
);
// Set idle bus high
_SDA1;
_SCL1;
// Set both output
GPIO_REG_WRITE(GPIO_ENABLE_ADDRESS, GPIO_REG_READ(GPIO_ENABLE_ADDRESS) | SDA_BIT | SCL_BIT);
return;
}
示例14: ioInit
void ioInit() {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
gpio_output_set((1<<LEDGPIO), 0, (1<<LEDGPIO), (1<<BTNGPIO));
os_timer_disarm(&resetBtntimer);
os_timer_setfn(&resetBtntimer, resetBtnTimerCb, NULL);
// os_timer_arm(&resetBtntimer, 500, 1);
}
示例15: miot_uart_dev_init
bool miot_uart_dev_init(struct miot_uart_state *us) {
struct miot_uart_config *cfg = us->cfg;
if (!esp_uart_validate_config(cfg)) return false;
ETS_INTR_DISABLE(ETS_UART_INUM);
uart_div_modify(us->uart_no, UART_CLK_FREQ / cfg->baud_rate);
if (us->uart_no == 0) {
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD);
if (cfg->swap_rxcts_txrts) {
SET_PERI_REG_MASK(PERIPHS_DPORT_BASEADDR + HOST_INF_SEL,
PERI_IO_UART0_PIN_SWAP);
} else {
CLEAR_PERI_REG_MASK(PERIPHS_DPORT_BASEADDR + HOST_INF_SEL,
PERI_IO_UART0_PIN_SWAP);
}
} else {
PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO2_U);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK);
if (cfg->swap_rxcts_txrts) {
SET_PERI_REG_MASK(PERIPHS_DPORT_BASEADDR + HOST_INF_SEL,
PERI_IO_UART1_PIN_SWAP);
} else {
CLEAR_PERI_REG_MASK(PERIPHS_DPORT_BASEADDR + HOST_INF_SEL,
PERI_IO_UART1_PIN_SWAP);
}
}
unsigned int conf0 = 0b011100; /* 8-N-1 */
if (cfg->tx_fc_ena) {
conf0 |= UART_TX_FLOW_EN;
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_U0CTS);
}
WRITE_PERI_REG(UART_CONF0(us->uart_no), conf0);
unsigned int conf1 = cfg->rx_fifo_full_thresh;
conf1 |= (cfg->tx_fifo_empty_thresh << 8);
if (cfg->rx_fifo_alarm >= 0) {
conf1 |= UART_RX_TOUT_EN | ((cfg->rx_fifo_alarm & 0x7f) << 24);
}
if (cfg->rx_fc_ena && cfg->rx_fifo_fc_thresh > 0) {
/* UART_RX_FLOW_EN will be set in uart_start. */
conf1 |= ((cfg->rx_fifo_fc_thresh & 0x7f) << 16);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_U0RTS);
}
WRITE_PERI_REG(UART_CONF1(us->uart_no), conf1);
s_us[us->uart_no] = us;
/* Start with TX and RX ints disabled. */
WRITE_PERI_REG(UART_INT_ENA(us->uart_no), UART_INFO_INTS);
ETS_UART_INTR_ATTACH(esp_uart_isr, NULL);
ETS_INTR_ENABLE(ETS_UART_INUM);
return true;
}