本文整理汇总了C++中ETS_GPIO_INTR_ENABLE函数的典型用法代码示例。如果您正苦于以下问题:C++ ETS_GPIO_INTR_ENABLE函数的具体用法?C++ ETS_GPIO_INTR_ENABLE怎么用?C++ ETS_GPIO_INTR_ENABLE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ETS_GPIO_INTR_ENABLE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flowTimerCb
static void ICACHE_FLASH_ATTR flowTimerCb(void) { // 1 second
if (flowOverridden) {
ETS_GPIO_INTR_DISABLE();
flowCount = 0;
ETS_GPIO_INTR_ENABLE();
} else {
ETS_GPIO_INTR_DISABLE();
oneSecFlowCount = flowCount;
flowCount = 0;
ETS_GPIO_INTR_ENABLE();
}
flowSetAverage(oneSecFlowCount);
if (flowAverage == 0) { // Use average to deal with any timing issues when demand oscillates
INFOP("!");
secondsNotFlowingCount++;
} else {
INFOP(">");
secondsNotFlowingCount = 0;
}
flowCountPerReading += oneSecFlowCount;
if (oneSecFlowCount < flowMin) {
flowMin = oneSecFlowCount;
}
if (oneSecFlowCount > flowMax) {
flowMax = oneSecFlowCount;
}
calcFlows();
}
示例2: 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 : NONE
* Returns : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR
i2c_master_gpio_init(uint8 scl, uint8 sda, uint32 bitrate)
{
pinSCL = scl;
pinSDA = sda;
#if 0
ETS_GPIO_INTR_DISABLE();
// ETS_INTR_LOCK();
// Assume the pin mux is set before calling this function
//PIN_FUNC_SELECT(I2C_MASTER_SDA_MUX, I2C_MASTER_SDA_FUNC);
//PIN_FUNC_SELECT(I2C_MASTER_SCL_MUX, I2C_MASTER_SCL_FUNC);
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_SDA_SCL(1, 1);
ETS_GPIO_INTR_ENABLE() ;
// ETS_INTR_UNLOCK();
#endif
I2C_MASTER_SDA_SCL(1, 1);
i2c_master_init();
}
示例3: spi
static void spi(uint8 c) {
uint8 mask = 0x80;
ETS_GPIO_INTR_DISABLE();
while (mask != 0) {
if (mask & c) {
// stdoutPutchar('1');
// easygpio_outputSet(LCD_Data, 1);
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, (1 << LCD_Data));
} else {
// stdoutPutchar('0');
// easygpio_outputSet(LCD_Data, 0);
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, (1 << LCD_Data));
}
mask >>= 1;
asm volatile (
"NOP;NOP;NOP;NOP;NOP;"
);
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, (1 << LCD_clk));
asm volatile (
"NOP;NOP;NOP;NOP;NOP;"
"NOP;NOP;NOP;NOP;NOP;"
);
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, (1 << LCD_clk));
}
ETS_GPIO_INTR_ENABLE();
// stdoutPutchar(' ');
}
示例4: GPIO_DIS_OUTPUT
// initialization
void IRrecv::enableIRIn() {
// initialize state machine variables
irparams.rcvstate = STATE_IDLE;
irparams.rawlen = 0;
// set pin modes
//PIN_FUNC_SELECT(IR_IN_MUX, IR_IN_FUNC);
GPIO_DIS_OUTPUT(irparams.recvpin);
// Initialize timer
os_timer_disarm(&timer);
os_timer_setfn(&timer, (os_timer_func_t *)read_timeout, &timer);
// ESP Attach Interrupt
ETS_GPIO_INTR_DISABLE();
ETS_GPIO_INTR_ATTACH(gpio_intr, NULL);
gpio_pin_intr_state_set(GPIO_ID_PIN(irparams.recvpin), GPIO_PIN_INTR_ANYEDGE);
ETS_GPIO_INTR_ENABLE();
//ETS_INTR_UNLOCK();
//attachInterrupt(irparams.recvpin, readIR, CHANGE);
//irReadTimer.initializeUs(USECPERTICK, readIR).start();
//os_timer_arm_us(&irReadTimer, USECPERTICK, 1);
//ets_timer_arm_new(&irReadTimer, USECPERTICK, 1, 0);
}
示例5: key_init
/******************************************************************************
* FunctionName : key_init
* Description : init keys
* Parameters : key_param *keys - keys parameter, which inited by key_init_single
* Returns : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
key_init(struct keys_param *keys)
{
uint8 i;
os_printf("-%s-%s \r\n", __FILE__, __func__);
ETS_GPIO_INTR_ATTACH(key_intr_handler, keys);
ETS_GPIO_INTR_DISABLE();
for (i = 0; i < keys->key_num; i++) {
keys->single_key[i]->key_level = 1;
PIN_FUNC_SELECT(keys->single_key[i]->gpio_name, keys->single_key[i]->gpio_func);
gpio_output_set(0, 0, 0, GPIO_ID_PIN(keys->single_key[i]->gpio_id));
gpio_register_set(GPIO_PIN_ADDR(keys->single_key[i]->gpio_id), GPIO_PIN_INT_TYPE_SET(GPIO_PIN_INTR_DISABLE)
| GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_DISABLE)
| GPIO_PIN_SOURCE_SET(GPIO_AS_PIN_SOURCE));
//clear gpio14 status
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(keys->single_key[i]->gpio_id));
//enable interrupt
gpio_pin_intr_state_set(GPIO_ID_PIN(keys->single_key[i]->gpio_id), GPIO_PIN_INTR_ANYEGDE);
}
ETS_GPIO_INTR_ENABLE();
}
示例6: easygpio_attachInterrupt
/**
* Sets the 'gpio_pin' pin as a GPIO and sets the interrupt to trigger on that pin.
* The 'interruptArg' is the function argument that will be sent to your interruptHandler
*/
bool ICACHE_FLASH_ATTR
easygpio_attachInterrupt(uint8_t gpio_pin, EasyGPIO_PullStatus pullStatus, void (*interruptHandler)(void *arg), void *interruptArg) {
uint32_t gpio_name;
uint8_t gpio_func;
if (gpio_pin == 16) {
os_printf("easygpio_setupInterrupt Error: GPIO16 does not have interrupts\n");
return false;
}
if (!easygpio_getGPIONameFunc(gpio_pin, &gpio_name, &gpio_func) ) {
return false;
}
ETS_GPIO_INTR_ATTACH(interruptHandler, interruptArg);
ETS_GPIO_INTR_DISABLE();
PIN_FUNC_SELECT(gpio_name, gpio_func);
easygpio_setupPullsByName(gpio_name, pullStatus);
// disable output
GPIO_DIS_OUTPUT(gpio_pin);
gpio_register_set(GPIO_PIN_ADDR(gpio_pin), GPIO_PIN_INT_TYPE_SET(GPIO_PIN_INTR_DISABLE)
| GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_DISABLE)
| GPIO_PIN_SOURCE_SET(GPIO_AS_PIN_SOURCE));
//clear gpio14 status
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(gpio_pin));
ETS_GPIO_INTR_ENABLE();
return true;
}
示例7: key_init
/******************************************************************************
* FunctionName : key_init
* Description : init keys
* Parameters : key_param *keys - keys parameter, which inited by key_init_single
* Returns : none
*******************************************************************************/
void ICACHE_FLASH_ATTR key_init() {
uint8 i;
ETS_GPIO_INTR_ATTACH(key_intr_handler, &key_parameters);
ETS_GPIO_INTR_DISABLE();
for (i = 0; i < key_parameters.key_num; i++) {
key_parameters.single_key[i]->key_level = 1;
key_parameters.single_key[i]->is_long = 0;
PIN_FUNC_SELECT(key_parameters.single_key[i]->gpio_name, key_parameters.single_key[i]->gpio_func);
// Set GPIO as input
gpio_output_set(0, 0, 0, GPIO_ID_PIN(key_parameters.single_key[i]->gpio_id));
gpio_register_set(
GPIO_PIN_ADDR(key_parameters.single_key[i]->gpio_id),
GPIO_PIN_INT_TYPE_SET(GPIO_PIN_INTR_DISABLE) |
GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_DISABLE) |
GPIO_PIN_SOURCE_SET(GPIO_AS_PIN_SOURCE)
);
//clear gpio14 status
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(key_parameters.single_key[i]->gpio_id));
//enable interrupt
gpio_pin_intr_state_set(GPIO_ID_PIN(key_parameters.single_key[i]->gpio_id), GPIO_PIN_INTR_NEGEDGE);
}
ETS_GPIO_INTR_ENABLE();
}
示例8: 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;
}
示例9: 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;
}
示例10: set_gpio_no_interrupt
/*
* Set GPIO mode to output. Optionally in RAM helper because interrupts are dsabled
*/
static void NO_INTR_CODE set_gpio_no_interrupt(uint8 pin, uint8_t push_pull) {
unsigned pnum = pin_num[pin];
ETS_GPIO_INTR_DISABLE();
#ifdef GPIO_INTERRUPT_ENABLE
pin_int_type[pin] = GPIO_PIN_INTR_DISABLE;
#endif
PIN_FUNC_SELECT(pin_mux[pin], pin_func[pin]);
//disable interrupt
gpio_pin_intr_state_set(GPIO_ID_PIN(pnum), GPIO_PIN_INTR_DISABLE);
//clear interrupt status
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(pnum));
// configure push-pull vs open-drain
if (push_pull) {
GPIO_REG_WRITE(GPIO_PIN_ADDR(GPIO_ID_PIN(pnum)),
GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(pnum))) &
(~ GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE))); //disable open drain;
} else {
GPIO_REG_WRITE(GPIO_PIN_ADDR(GPIO_ID_PIN(pnum)),
GPIO_REG_READ(GPIO_PIN_ADDR(GPIO_ID_PIN(pnum))) |
GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)); //enable open drain;
}
ETS_GPIO_INTR_ENABLE();
}
示例11: button_press
void ICACHE_FLASH_ATTR
button_press() {
ETS_GPIO_INTR_DISABLE(); // Disable gpio interrupts
// Button interrupt received
INFO("BUTTON: Button pressed\r\n");
// Button pressed, flip switch
if (GPIO_REG_READ(BUTTON_GPIO) & BIT2) {
INFO("BUTTON: Switch off\r\n");
GPIO_OUTPUT_SET(SWITCH03_GPIO, 0);
} else {
INFO("BUTTON: Switch on\r\n");
GPIO_OUTPUT_SET(SWITCH03_GPIO, 1);
}
// Send new status to the MQTT broker
char *json_buf = NULL;
json_buf = (char *)os_zalloc(jsonSize);
json_ws_send((struct jsontree_value *)&device_tree, "device", json_buf);
INFO("BUTTON: Sending current switch status\r\n");
MQTT_Publish(&mqttClient, config.mqtt_topic_s01, json_buf, strlen(json_buf), 0, 0);
os_free(json_buf);
json_buf = NULL;
// Debounce
os_delay_us(200000);
// Clear interrupt status
uint32 gpio_status;
gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status);
ETS_GPIO_INTR_ENABLE(); // Enable gpio interrupts
}
示例12: supla_esp_gpio_init_led
void supla_esp_gpio_init_led(void) {
ETS_GPIO_INTR_DISABLE();
#ifdef LED_RED_PORT
#if LED_RED_PORT != 16
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(LED_RED_PORT));
gpio_pin_intr_state_set(GPIO_ID_PIN(LED_RED_PORT), GPIO_PIN_INTR_DISABLE);
gpio_output_set(0, GPIO_ID_PIN(LED_RED_PORT), GPIO_ID_PIN(LED_RED_PORT), 0);
#endif
#endif
#ifdef LED_GREEN_PORT
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(LED_GREEN_PORT));
gpio_pin_intr_state_set(GPIO_ID_PIN(LED_GREEN_PORT), GPIO_PIN_INTR_DISABLE);
gpio_output_set(0, GPIO_ID_PIN(LED_GREEN_PORT), GPIO_ID_PIN(LED_GREEN_PORT), 0);
#endif
#ifdef LED_BLUE_PORT
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(LED_BLUE_PORT));
gpio_pin_intr_state_set(GPIO_ID_PIN(LED_BLUE_PORT), GPIO_PIN_INTR_DISABLE);
gpio_output_set(0, GPIO_ID_PIN(LED_BLUE_PORT), GPIO_ID_PIN(LED_BLUE_PORT), 0);
#endif
ETS_GPIO_INTR_ENABLE();
}
示例13: user_init
void ICACHE_FLASH_ATTR user_init()
{
// Initialize the GPIO subsystem.
//UART_init(BIT_RATE_115200, BIT_RATE_115200, 0);
//UART_SetPrintPort(UART0);
stdout_init();
i2c_master_gpio_init();
user_set_station_config();
pcf8754_i2c_write_byte(I2C_INPUT_ADDRESS, 0);
// =================================================
// Initialize GPIO2 and GPIO0 as GPIO
// =================================================
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_GPIO3);
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0RXD_U);
gpio_output_set(0, 0, 0, GPIO_ID_PIN(3)); // set set gpio 0 as input
ETS_GPIO_INTR_DISABLE();
// Attach interrupt handle to gpio interrupts.
ETS_GPIO_INTR_ATTACH(gpio_intr_handler, NULL);
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(3)); // clear gpio status
gpio_pin_intr_state_set(GPIO_ID_PIN(3), GPIO_PIN_INTR_ANYEDGE); // clear gpio status.
ETS_GPIO_INTR_ENABLE(); // Enable interrupts by GPIO
// register a callback function to let user code know that system
// initialization is complete
system_init_done_cb(&post_user_init_func);
//Start os task
system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
}
示例14: set_gpio_interrupt
static void NO_INTR_CODE set_gpio_interrupt(uint8 pin) {
ETS_GPIO_INTR_DISABLE();
PIN_FUNC_SELECT(pin_mux[pin], pin_func[pin]);
GPIO_DIS_OUTPUT(pin_num[pin]);
gpio_register_set(GPIO_PIN_ADDR(GPIO_ID_PIN(pin_num[pin])),
GPIO_PIN_INT_TYPE_SET(GPIO_PIN_INTR_DISABLE)
| GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_DISABLE)
| GPIO_PIN_SOURCE_SET(GPIO_AS_PIN_SOURCE));
ETS_GPIO_INTR_ENABLE();
}
示例15: user_plug_set_status
/******************************************************************************
* FunctionName : user_plug_set_status
* Description : set plug's status, 0x00 or 0x01
* Parameters : uint8 - status
* Returns : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_plug_set_status(bool status)
{
// if (status != plug_param.status) {
// if (status > 1) {
// os_printf("error status input!\n");
// return;
// }
//
// plug_param.status = status;
// PLUG_STATUS_OUTPUT(PLUG_RELAY_LED_IO_NUM, status);
// }
if (status != plug_param.status) {
if (status > 1) {
os_printf("error status input!\n");
return;
}
plug_param.status = status;
//PLUG_STATUS_OUTPUT(PLUG_RELAY_LED_IO_NUM, status);
ETS_GPIO_INTR_DISABLE();
PIN_FUNC_SELECT(pin_mux[pin], pin_func[pin]);
GPIO_DIS_OUTPUT(pin_num[pin]);
gpio_register_set(GPIO_PIN_ADDR(GPIO_ID_PIN(pin_num[pin])), GPIO_PIN_INT_TYPE_SET(GPIO_PIN_INTR_DISABLE)
| GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_DISABLE)
| GPIO_PIN_SOURCE_SET(GPIO_AS_PIN_SOURCE));
ETS_GPIO_INTR_ENABLE();
//disable global interrupt
ETS_GPIO_INTR_DISABLE();
//clear interrupt status
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(pin_num[pin]));
pin_int_type[pin] = type;
//enable interrupt
gpio_pin_intr_state_set(GPIO_ID_PIN(pin_num[pin]), type);
//enable global interrupt
ETS_GPIO_INTR_ENABLE();
ETS_GPIO_INTR_ATTACH(func, arg)
}
}