void setup (void) { // hal.scheduler->delay(5000); hal.console->printf_P(PSTR("Starting AP_HAL_AVR::Scheduler test\r\n")); setup_pin(DELAY_TOGGLE_PIN); setup_pin(FAILSAFE_TOGGLE_PIN); setup_pin(SCHEDULED_TOGGLE_PIN_1); setup_pin(SCHEDULED_TOGGLE_PIN_2); hal.console->printf_P(PSTR("Testing delay callback. " "Pin %d should toggle at 1khz:\r\n"), (int) DELAY_TOGGLE_PIN); // hal.scheduler->register_delay_callback(delay_toggle,0); hal.scheduler->delay(2000); hal.console->printf_P(PSTR("Testing failsafe callback. " "Pin %d should toggle at 1khz:\r\n"), (int) FAILSAFE_TOGGLE_PIN); hal.scheduler->register_timer_failsafe(failsafe_toggle, 1000); hal.scheduler->delay(2000); hal.console->printf_P(PSTR("Testing running timer processes.\r\n")); hal.console->printf_P(PSTR("Pin %d should toggle at 1khz.\r\n"), (int) SCHEDULED_TOGGLE_PIN_1); hal.console->printf_P(PSTR("Pin %d should toggle at 1khz.\r\n"), (int) SCHEDULED_TOGGLE_PIN_2); hal.scheduler->register_timer_process(schedule_toggle_1); hal.scheduler->register_timer_process(schedule_toggle_2); hal.scheduler->delay(2000); // not yet working on flymaple: see FLYMAPLEScheduler::_timer_procs_timer_event() #if 1 hal.console->printf_P(PSTR("Test running a pathological timer process.\r\n" "Failsafe should continue even as pathological process " "dominates the processor.")); hal.console->printf_P(PSTR("Pin %d should toggle then go high forever.\r\n"), (int) SCHEDULED_TOGGLE_PIN_2); hal.scheduler->delay(200); hal.scheduler->register_timer_process(schedule_toggle_hang); #endif // Wait a little then test reboot // hal.scheduler->delay(5000); // hal.scheduler->reboot(); }
void setup (void) { hal.console->printf_P(PSTR("Starting Semaphore test\r\n")); setup_pin(PIN_A0); setup_pin(PIN_A1); setup_pin(PIN_A2); setup_pin(PIN_A3); hal.console->printf_P(PSTR("Using Dataflash's Semaphore\r\n")); AP_HAL::SPIDeviceDriver *dataflash = hal.spi->device( AP_HAL::SPIDevice_Dataflash); if (dataflash == NULL) { hal.scheduler->panic(PSTR("Error: No SPIDevice_Dataflash driver!")); } sem = dataflash->get_semaphore(); if (sem == NULL) { hal.scheduler->panic(PSTR("Error: No SPIDeviceDriver semaphore!")); } hal.scheduler->register_timer_process(async_blinker, NULL); }
void node_stop(uint8_t *aInCfg) { // enter stop enter_node_stop(); #ifdef AUTOMATION // set up pin based on msg setup_pin(aInCfg); #else // ifndef AUTOMATION // unused pins GPIO_config_all_unused(); #endif // AUTOMATION PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); // now wake up leave_node_stop(); }
void setup_switching(void){ setup_pin(true,SIDE_1_ENABLE); setup_pin(true,SIDE_2_ENABLE); setup_pin(true,BIT_0_CONTROL); setup_pin(true,BIT_1_CONTROL); }
static int egpio_probe(struct platform_device *pdev) { struct htc_egpio_platform_data *pdata = pdev->dev.platform_data; struct resource *res; struct egpio_info *ei; int irq, i, ret; struct gpio_ops ops; /* Initialize ei data structure. */ //obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o ei = kzalloc(sizeof(*ei), GFP_KERNEL); if (!ei) return -ENOMEM; spin_lock_init(&ei->lock); /* Find chained irq */ ret = -EINVAL; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (res) ei->chainedirq = res->start; /* Map egpio chip into virtual address space. */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) goto fail; ei->addrBase = (u16 *)ioremap_nocache(res->start, res->end - res->start); if (!ei->addrBase) goto fail; printk(KERN_NOTICE "EGPIO phys=%08x virt=%p\n" , res->start, ei->addrBase); ei->bus_shift = pdata->bus_shift; platform_set_drvdata(pdev, ei); ops.get_value = egpio_get; ops.set_value = egpio_set; ops.to_irq = egpio_to_irq; gpiodev_register(pdata->gpio_base, &pdev->dev, &ops); /* Go through list of pins. */ ei->irqStart = pdata->irq_base; ei->maxRegs = pdata->nrRegs - 1; ei->ackRegister = pdata->ackRegister; for (i = 0; i < pdata->nr_pins; i++) setup_pin(ei, &pdata->pins[i]); if (ei->chainedirq) { /* Setup irq handlers */ ei->ackWrite = 0xFFFF; if (pdata->invertAcks) ei->ackWrite = 0; for (irq = ei->irqStart; irq < ei->irqStart+MAX_EGPIO_IRQS; irq++) { set_irq_chip(irq, &egpio_muxed_chip); set_irq_chip_data(irq, ei); set_irq_handler(irq, handle_simple_irq); set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); } set_irq_type(ei->chainedirq, IRQT_RISING); set_irq_data(ei->chainedirq, ei); set_irq_chained_handler(ei->chainedirq, egpio_handler); ackirqs(ei); device_init_wakeup(&pdev->dev, 1); } /* Setup initial output pin values. */ for (i = 0; i<=ei->maxRegs; i++) if (i != ei->ackRegister) writew(ei->cached_values[i], &ei->addrBase[i << ei->bus_shift]); return 0; fail: printk(KERN_NOTICE "EGPIO failed to setup\n"); kfree(ei); return ret; }