/*---------------------------------------------------------------------------*/ static int configure(int type, int value) { if(type != MOTION_ACTIVE) { PRINTF("Motion: invalid configuration option\n"); return MOTION_ERROR; } if(!value) { presence_int_callback = NULL; GPIO_DISABLE_INTERRUPT(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK); return MOTION_SUCCESS; } /* Configure interruption */ GPIO_SOFTWARE_CONTROL(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK); GPIO_SET_INPUT(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK); GPIO_DETECT_RISING(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK); GPIO_TRIGGER_SINGLE_EDGE(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK); ioc_set_over(MOTION_SENSOR_PORT, MOTION_SENSOR_PIN, IOC_OVERRIDE_DIS); gpio_register_callback(motion_interrupt_handler, MOTION_SENSOR_PORT, MOTION_SENSOR_PIN); process_start(&motion_int_process, NULL); GPIO_ENABLE_INTERRUPT(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK); nvic_interrupt_enable(MOTION_SENSOR_VECTOR); return MOTION_SUCCESS; }
void setup_plug_detect_pin() { gpio_register_callback(plug_detect, PLUG_DETECT_PORT_NUM, PLUG_DETECT_PIN_NUM); GPIO_DETECT_RISING(PLUG_DETECT_PORT_BASE, PLUG_DETECT_PIN_MASK); GPIO_POWER_UP_ON_RISING(PLUG_DETECT_PORT_NUM, PLUG_DETECT_PIN_MASK); GPIO_CLEAR_INTERRUPT(PLUG_DETECT_PORT_BASE, PLUG_DETECT_PIN_MASK); GPIO_CLEAR_POWER_UP_INTERRUPT(PLUG_DETECT_PORT_NUM, PLUG_DETECT_PIN_MASK); GPIO_ENABLE_INTERRUPT(PLUG_DETECT_PORT_BASE, PLUG_DETECT_PIN_MASK); GPIO_ENABLE_POWER_UP_INTERRUPT(PLUG_DETECT_PORT_NUM, PLUG_DETECT_PIN_MASK); }
/*---------------------------------------------------------------------------*/ static int configure(int type, int value) { if(type != SENSORS_ACTIVE) { return DIMMER_ERROR; } if(value) { /* This is the Triac's gate pin */ GPIO_SOFTWARE_CONTROL(DIMMER_GATE_PORT_BASE, DIMMER_GATE_PIN_MASK); GPIO_SET_OUTPUT(DIMMER_GATE_PORT_BASE, DIMMER_GATE_PIN_MASK); ioc_set_over(DIMMER_GATE_PORT, DIMMER_GATE_PIN, IOC_OVERRIDE_OE); GPIO_CLR_PIN(DIMMER_GATE_PORT_BASE, DIMMER_GATE_PIN_MASK); /* This is the zero-crossing pin and interrupt */ GPIO_SOFTWARE_CONTROL(DIMMER_SYNC_PORT_BASE, DIMMER_SYNC_PIN_MASK); GPIO_SET_INPUT(DIMMER_SYNC_PORT_BASE, DIMMER_SYNC_PIN_MASK); /* Pull-up resistor, detect rising edge */ GPIO_DETECT_EDGE(DIMMER_SYNC_PORT_BASE, DIMMER_SYNC_PIN_MASK); GPIO_TRIGGER_SINGLE_EDGE(DIMMER_SYNC_PORT_BASE, DIMMER_SYNC_PIN_MASK); GPIO_DETECT_RISING(DIMMER_SYNC_PORT_BASE, DIMMER_SYNC_PIN_MASK); gpio_register_callback(dimmer_zero_cross_int_handler, DIMMER_SYNC_PORT, DIMMER_SYNC_PIN); /* Spin process until an interrupt is received */ process_start(&ac_dimmer_int_process, NULL); /* Enable interrupts */ GPIO_ENABLE_INTERRUPT(DIMMER_SYNC_PORT_BASE, DIMMER_SYNC_PIN_MASK); // ioc_set_over(DIMMER_SYNC_PORT, DIMMER_SYNC_PIN, IOC_OVERRIDE_PUE); NVIC_EnableIRQ(DIMMER_INT_VECTOR); enabled = 1; dimming = DIMMER_DEFAULT_START_VALUE; return DIMMER_SUCCESS; } /* Disable interrupt and pins */ GPIO_DISABLE_INTERRUPT(DIMMER_SYNC_PORT_BASE, DIMMER_SYNC_PIN_MASK); GPIO_SET_INPUT(DIMMER_GATE_PORT_BASE, DIMMER_GATE_PIN_MASK); GPIO_SET_OUTPUT(DIMMER_SYNC_PORT_BASE, DIMMER_SYNC_PIN_MASK); process_exit(&ac_dimmer_int_process); enabled = 0; dimming = 0; return DIMMER_SUCCESS; }
//Use C0 to receive interrupt void configGPIOInterrupt(){ GPIO_SOFTWARE_CONTROL(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(0)); GPIO_SET_INPUT(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(0)); GPIO_DETECT_EDGE(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(0)); GPIO_DETECT_RISING(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(0)); GPIO_ENABLE_INTERRUPT(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(0)); GPIO_SOFTWARE_CONTROL(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(2)); GPIO_SET_INPUT(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(2)); GPIO_DETECT_EDGE(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(2)); GPIO_DETECT_FALLING(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(2)); GPIO_ENABLE_INTERRUPT(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(2)); ioc_set_over(GPIO_C_NUM,0, IOC_OVERRIDE_PUE); ioc_set_over(GPIO_C_NUM,2, IOC_OVERRIDE_PUE); nvic_interrupt_enable(NVIC_INT_GPIO_PORT_C); gpio_register_callback(cb,GPIO_C_NUM,0); gpio_register_callback(cb,GPIO_C_NUM,2); }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(gpiot_process, ev, data) { PROCESS_BEGIN(); etimer_set(&periodic_timer_gpio, CLOCK_SECOND/10); GPIO_SOFTWARE_CONTROL(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(0)); GPIO_SET_INPUT(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(0));//input: pin: C0 GPIO_DETECT_EDGE(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(0)); GPIO_TRIGGER_SINGLE_EDGE(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(0)); GPIO_DETECT_RISING(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(0)); GPIO_ENABLE_INTERRUPT(GPIO_PORT_TO_BASE(GPIO_C_NUM), GPIO_PIN_MASK(0)); ioc_set_over(GPIO_C_NUM, 0, IOC_OVERRIDE_PUE); nvic_interrupt_enable(NVIC_INT_GPIO_PORT_C); gpio_register_callback(gp_int,GPIO_C_NUM, 0); while(1) { PROCESS_YIELD(); leds_toggle(LEDS_RED); etimer_restart(&periodic_timer_gpio); } PROCESS_END(); }
/** * \brief Initialize the nRF51822. */ void nrf51822_init() { // Setup interrupt from nRF51822 GPIO_SOFTWARE_CONTROL(NRF51822_INT_BASE, NRF51822_INT_MASK); GPIO_SET_INPUT(NRF51822_INT_BASE, NRF51822_INT_MASK); GPIO_DETECT_EDGE(NRF51822_INT_BASE, NRF51822_INT_MASK); GPIO_TRIGGER_SINGLE_EDGE(NRF51822_INT_BASE, NRF51822_INT_MASK); GPIO_DETECT_RISING(NRF51822_INT_BASE, NRF51822_INT_MASK); GPIO_ENABLE_INTERRUPT(NRF51822_INT_BASE, NRF51822_INT_MASK); ioc_set_over(NRF51822_INT_PORT_NUM, 0, IOC_OVERRIDE_DIS); nvic_interrupt_enable(NVIC_INT_GPIO_PORT_B); gpio_register_callback(nrf51822_interrupt, NRF51822_INT_PORT_NUM, NRF51822_INT_PIN); spi_cs_init(NRF51822_CS_N_PORT_NUM, NRF51822_CS_N_PIN); SPI_CS_SET(NRF51822_CS_N_PORT_NUM, NRF51822_CS_N_PIN); }
/** * \brief Common initialiser for all buttons * \param port_base GPIO port's register offset * \param pin_mask Pin mask corresponding to the button's pin */ static void config(uint32_t port_base, uint32_t pin_mask) { /* Software controlled */ GPIO_SOFTWARE_CONTROL(port_base, pin_mask); /* Set pin to input */ GPIO_SET_INPUT(port_base, pin_mask); /* Enable edge detection */ GPIO_DETECT_EDGE(port_base, pin_mask); /* Single edge */ GPIO_TRIGGER_SINGLE_EDGE(port_base, pin_mask); /* Trigger interrupt on Falling edge */ GPIO_DETECT_RISING(port_base, pin_mask); GPIO_ENABLE_INTERRUPT(port_base, pin_mask); }
/*---------------------------------------------------------------------------*/ void cc1200_arch_gpio2_setup_irq(int rising) { GPIO_SOFTWARE_CONTROL(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK); GPIO_SET_INPUT(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK); GPIO_DETECT_EDGE(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK); GPIO_TRIGGER_SINGLE_EDGE(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK); if(rising) { GPIO_DETECT_RISING(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK); } else { GPIO_DETECT_FALLING(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK); } GPIO_ENABLE_INTERRUPT(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK); ioc_set_over(CC1200_GDO2_PORT, CC1200_GDO2_PIN, IOC_OVERRIDE_PUE); NVIC_EnableIRQ(CC1200_GPIOx_VECTOR); gpio_register_callback(cc1200_int_handler, CC1200_GDO2_PORT, CC1200_GDO2_PIN); }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(mainProcess, ev, data) { PROCESS_BEGIN(); GPIO_SET_OUTPUT(GPIO_A_BASE, 0xf8); GPIO_SET_OUTPUT(GPIO_B_BASE, 0x0f); GPIO_SET_OUTPUT(GPIO_C_BASE, 0x02); GPIO_CLR_PIN(GPIO_A_BASE, 0xf8); GPIO_CLR_PIN(GPIO_B_BASE, 0x07); GPIO_SET_PIN(EDISON_WAKEUP_BASE, EDISON_WAKEUP_PIN_MASK); // edison WAKEUP GPIO_SET_INPUT(RESET_PORT_BASE, RESET_PIN_MASK); // reset ioc_set_over(RESET_PORT, RESET_PIN, IOC_OVERRIDE_PUE); leds_off(LEDS_RED); leds_off(LEDS_GREEN); leds_off(LEDS_BLUE); // RESET interrupt, active low GPIO_DETECT_EDGE(RESET_PORT_BASE, RESET_PIN_MASK); GPIO_DETECT_FALLING(RESET_PORT_BASE, RESET_PIN_MASK); GPIO_TRIGGER_SINGLE_EDGE(RESET_PORT_BASE, RESET_PIN_MASK); gpio_register_callback(resetcallBack, RESET_PORT, RESET_PIN); GPIO_ENABLE_INTERRUPT(RESET_PORT_BASE, RESET_PIN_MASK); nvic_interrupt_enable(RESET_NVIC_PORT); GPIO_CLR_PIN(TRIUMVI_DATA_READY_PORT_BASE, TRIUMVI_DATA_READY_MASK); // SPI CS interrupt GPIO_DETECT_EDGE(SPI0_CS_PORT_BASE, SPI0_CS_PIN_MASK); GPIO_DETECT_RISING(SPI0_CS_PORT_BASE, SPI0_CS_PIN_MASK); GPIO_TRIGGER_SINGLE_EDGE(SPI0_CS_PORT_BASE, SPI0_CS_PIN_MASK); gpio_register_callback(spiCScallBack, SPI0_CS_PORT, SPI0_CS_PIN); GPIO_ENABLE_INTERRUPT(SPI0_CS_PORT_BASE, SPI0_CS_PIN_MASK); // SPI interface spix_slave_init(SPIDEV); spix_txdma_enable(SPIDEV); spi_register_callback(spiFIFOcallBack); spix_interrupt_enable(SPIDEV, SSI_IM_RXIM_M); // RX FIFO half full nvic_interrupt_enable(NVIC_INT_SSI0); // uDMA SPI0 TX udma_channel_disable(CC2538_SPI0_TX_DMA_CHAN); udma_channel_prio_set_default(CC2538_SPI0_TX_DMA_CHAN); udma_channel_use_primary(CC2538_SPI0_TX_DMA_CHAN); udma_channel_use_single(CC2538_SPI0_TX_DMA_CHAN); udma_channel_mask_clr(CC2538_SPI0_TX_DMA_CHAN); udma_set_channel_dst(CC2538_SPI0_TX_DMA_CHAN, SPI0DR); udma_set_channel_assignment(CC2538_SPI0_TX_DMA_CHAN, UDMA_CH11_SSI0TX); simple_network_set_callback(&rf_rx_handler); //NETSTACK_RADIO.off(); process_start(&decryptProcess, NULL); process_start(&spiProcess, NULL); while (1){ PROCESS_YIELD(); // buffer is not empty, spi is not in use //if ((spiInUse==0) && (spix_busy(SPIDEV)==0) && ((triumviAvailIDX!=triumviFullIDX) || (triumviRXBufFull==1))){ if ((spiInUse==0) && ((triumviAvailIDX!=triumviFullIDX) || (triumviRXBufFull==1))){ GPIO_SET_PIN(TRIUMVI_DATA_READY_PORT_BASE, TRIUMVI_DATA_READY_MASK); if (triumviRXBufFull==1){ resetCnt += 1; if (resetCnt==RESET_THRESHOLD){ watchdog_reboot(); } } #ifdef LED_DEBUG leds_off(LEDS_RED); leds_off(LEDS_GREEN); leds_off(LEDS_BLUE); #endif } // Fail safe, CC2538 missing some SPI commands, reset spi state else if (triumviRXBufFull==1){ spiState = SPI_RESET; process_poll(&spiProcess); #ifdef LED_DEBUG leds_off(LEDS_RED); leds_off(LEDS_GREEN); leds_on(LEDS_BLUE); #endif } } PROCESS_END(); }
PROCESS_THREAD(MPU_DATA, ev, data) { static struct etimer sdtimer; PROCESS_BEGIN(); if(isInitialized==0) { // Turn off 3.3-V domain (lcd/sdcard power, output low) //GPIOPinTypeGPIOOutput(BSP_3V3_EN_BASE, BSP_3V3_EN); //GPIOPinWrite(BSP_3V3_EN_BASE, BSP_3V3_EN, 0); GPIO_SET_OUTPUT(BSP_3V3_EN_BASE, BSP_3V3_EN); GPIO_CLR_PIN(BSP_3V3_EN_BASE, BSP_3V3_EN); // If 3.3-V domain is initially off, make sure it's off >1 ms for a complete // sd card power cycle // Approx 10 ms delay Delay_ms(10); // Enable 3.3-V domain (it takes <= 600 us to stabilize) //GPIOPinWrite(BSP_3V3_EN_BASE, BSP_3V3_EN, BSP_3V3_EN); // high GPIO_SET_PIN(BSP_3V3_EN_BASE, BSP_3V3_EN); Delay_ms(100);//100ms //Disable LCD //GPIOPinTypeGPIOOutput(GPIO_B_BASE, (5)); //GPIOPinWrite(GPIO_B_BASE, (5), (5)); GPIO_SET_OUTPUT(GPIO_B_BASE, GPIO_PIN_MASK(5)); GPIO_SET_PIN(GPIO_B_BASE, GPIO_PIN_MASK(5)); GPIO_SET_INPUT(GPIO_B_BASE, GPIO_PIN_MASK(3)); GPIO_CLEAR_INTERRUPT(GPIO_B_BASE, 0xFF); GPIO_ENABLE_INTERRUPT(GPIO_B_BASE, 0X08); GPIO_DETECT_RISING(GPIO_B_BASE, 0X08); //Turn on Bluetooth //GPIO_SET_OUTPUT(GPIO_D_BASE, GPIO_PIN_MASK(3)); //GPIO_SET_PIN(GPIO_D_BASE, GPIO_PIN_MASK(3)); uart_init(UART_CONF_BASE); GPIO_SET_OUTPUT(GPIO_B_BASE, GPIO_PIN_MASK(6)); GPIO_CLR_PIN(GPIO_B_BASE, GPIO_PIN_MASK(6)); clock_delay(6000); GPIO_SET_PIN(GPIO_B_BASE, GPIO_PIN_MASK(6)); clock_delay(6000); init_i2c(); clock_delay(6000); init_MPU9150 (); isInitialized = 1; } while(1) { // PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&sdtimer)); //GPIO_SET_PIN(GPIO_C_BASE, lGPIO_PIN_MASK(2)); etimer_set(&sdtimer, CLOCK_SECOND/400); //TODO: change from 80 ---> 200 PROCESS_YIELD(); //GPIO_SET_PIN(GPIO_C_BASE, GPIO_PIN_MASK(1)); #define GPIO_B_BASE 0x400DA000 // GPIO #define GPIO_PIN_3 0x00000008 // GPIO pin 3 uint32_t gpio = REG(GPIO_B_BASE + (0x00000000 + (GPIO_PIN_3 << 2))) & GPIO_PIN_3; if(gpio) { read_sensor_data(IMU.Payload); PKT_NUM ++; IMU_PACKET[0]=IMU.Payload[0]; IMU_PACKET[1]=IMU.Payload[1]; IMU_PACKET[2]=IMU.Payload[2]; IMU_PACKET[3]=IMU.Payload[3]; IMU_PACKET[4]=IMU.Payload[4]; IMU_PACKET[5]=IMU.Payload[5]; IMU_PACKET[6]=IMU.Payload[6]; IMU_PACKET[7]=IMU.Payload[7]; IMU_PACKET[8]=IMU.Payload[8]; IMU_PACKET[9]=IMU.Payload[9]; IMU_PACKET[10]=IMU.Payload[10]; IMU_PACKET[11]=IMU.Payload[11]; IMU_PACKET[12]=IMU.Payload[12]; IMU_PACKET[13]=IMU.Payload[13]; IMU_PACKET[14]=IMU.Payload[14]; IMU_PACKET[15]=IMU.Payload[15]; IMU_PACKET[16]=IMU.Payload[16]; IMU_PACKET[17]=IMU.Payload[17]; if (cycle==1) { IMU_PACKET[18]=IMU.RSS1; IMU_PACKET[19]=IMU.RSS2; IMU_PACKET[20]=IMU.RSS3; IMU_PACKET[21]=IMU.RSS4; if (vat==0) { GPIO_SET_OUTPUT(GPIO_C_BASE, GPIO_PIN_MASK(0)); GPIO_SET_PIN(GPIO_C_BASE, GPIO_PIN_MASK(0)); vat=1; } else if (vat==1) { GPIO_CLR_PIN(GPIO_C_BASE, GPIO_PIN_MASK(0)); vat=0; } cycle=0; } else if (cycle==0) { IMU_PACKET[18]=0; IMU_PACKET[19]=0; IMU_PACKET[20]=0; IMU_PACKET[21]=0; } // Add packet number, so we can detect packet loss. IMU_PACKET[22]=PKT_NUM & 0x00ff; IMU_PACKET[23]=PKT_NUM >> 8 & 0x00ff ; unsigned char outLen = 0; byteStuff (&IMU_PACKET[0], PKT_LEN, outPkt, &outLen); char i; for(i=0; i<outLen; i++) { uart_write_byte(0,outPkt[i]); } } //push_data_to_buffer_imu(); /* if ((stage_imu==1) &&(SD_BUSY==0)) writedata_imu(); */ } PROCESS_END(); }
/*---------------------------------------------------------------------------*/ static int configure(int type, int value) { if((type != WEATHER_METER_ACTIVE) && (type != WEATHER_METER_ANEMOMETER_INT_OVER) && (type != WEATHER_METER_RAIN_GAUGE_INT_OVER) && (type != WEATHER_METER_ANEMOMETER_INT_DIS) && (type != WEATHER_METER_RAIN_GAUGE_INT_DIS)) { PRINTF("Weather: invalid configuration option\n"); return WEATHER_METER_ERROR; } if(type == WEATHER_METER_ACTIVE) { anemometer.value_avg = 0; anemometer.ticks_avg = 0; weather_sensors.anemometer.int_en = 0; weather_sensors.rain_gauge.int_en = 0; weather_sensors.anemometer.ticks = 0; weather_sensors.rain_gauge.ticks = 0; weather_sensors.anemometer.value = 0; weather_sensors.rain_gauge.value = 0; if(!value) { anemometer_int_callback = NULL; rain_gauge_int_callback = NULL; GPIO_DISABLE_INTERRUPT(ANEMOMETER_SENSOR_PORT_BASE, ANEMOMETER_SENSOR_PIN_MASK); GPIO_DISABLE_INTERRUPT(RAIN_GAUGE_SENSOR_PORT_BASE, RAIN_GAUGE_SENSOR_PIN_MASK); process_exit(&weather_meter_int_process); enabled = 0; PRINTF("Weather: disabled\n"); return WEATHER_METER_SUCCESS; } /* Configure the wind vane */ adc_zoul.configure(SENSORS_HW_INIT, WIND_VANE_ADC); /* Configure anemometer interruption */ GPIO_SOFTWARE_CONTROL(ANEMOMETER_SENSOR_PORT_BASE, ANEMOMETER_SENSOR_PIN_MASK); GPIO_SET_INPUT(ANEMOMETER_SENSOR_PORT_BASE, ANEMOMETER_SENSOR_PIN_MASK); GPIO_DETECT_RISING(ANEMOMETER_SENSOR_PORT_BASE, ANEMOMETER_SENSOR_PIN_MASK); GPIO_TRIGGER_SINGLE_EDGE(ANEMOMETER_SENSOR_PORT_BASE, ANEMOMETER_SENSOR_PIN_MASK); ioc_set_over(ANEMOMETER_SENSOR_PORT, ANEMOMETER_SENSOR_PIN, IOC_OVERRIDE_DIS); gpio_register_callback(weather_meter_interrupt_handler, ANEMOMETER_SENSOR_PORT, ANEMOMETER_SENSOR_PIN); /* Configure rain gauge interruption */ GPIO_SOFTWARE_CONTROL(RAIN_GAUGE_SENSOR_PORT_BASE, RAIN_GAUGE_SENSOR_PIN_MASK); GPIO_SET_INPUT(RAIN_GAUGE_SENSOR_PORT_BASE, RAIN_GAUGE_SENSOR_PIN_MASK); GPIO_DETECT_RISING(RAIN_GAUGE_SENSOR_PORT_BASE, RAIN_GAUGE_SENSOR_PIN_MASK); GPIO_TRIGGER_SINGLE_EDGE(RAIN_GAUGE_SENSOR_PORT_BASE, RAIN_GAUGE_SENSOR_PIN_MASK); ioc_set_over(RAIN_GAUGE_SENSOR_PORT, RAIN_GAUGE_SENSOR_PIN, IOC_OVERRIDE_DIS); gpio_register_callback(weather_meter_interrupt_handler, RAIN_GAUGE_SENSOR_PORT, RAIN_GAUGE_SENSOR_PIN); process_start(&weather_meter_int_process, NULL); /* Initialize here prior the first second tick */ wind_vane.value_prev = weather_meter_get_wind_dir(); ctimer_set(&ct, CLOCK_SECOND, ct_callback, NULL); GPIO_ENABLE_INTERRUPT(ANEMOMETER_SENSOR_PORT_BASE, ANEMOMETER_SENSOR_PIN_MASK); GPIO_ENABLE_INTERRUPT(RAIN_GAUGE_SENSOR_PORT_BASE, RAIN_GAUGE_SENSOR_PIN_MASK); nvic_interrupt_enable(ANEMOMETER_SENSOR_VECTOR); nvic_interrupt_enable(RAIN_GAUGE_SENSOR_VECTOR); enabled = 1; PRINTF("Weather: started\n"); return WEATHER_METER_SUCCESS; } switch(type) { case WEATHER_METER_ANEMOMETER_INT_OVER: weather_sensors.anemometer.int_en = 1; weather_sensors.anemometer.int_thres = value; PRINTF("Weather: anemometer threshold %u\n", value); break; case WEATHER_METER_RAIN_GAUGE_INT_OVER: weather_sensors.rain_gauge.int_en = 1; weather_sensors.rain_gauge.int_thres = value; PRINTF("Weather: rain gauge threshold %u\n", value); break; case WEATHER_METER_ANEMOMETER_INT_DIS: PRINTF("Weather: anemometer int disabled\n"); weather_sensors.anemometer.int_en = 0; break; case WEATHER_METER_RAIN_GAUGE_INT_DIS: PRINTF("Weather: rain gauge int disabled\n"); weather_sensors.rain_gauge.int_en = 0; break; default: return WEATHER_METER_ERROR; } return WEATHER_METER_SUCCESS; }