Exemplo n.º 1
0
/* main ===================================================================== */
int
main (void) {
  static volatile int i;

  vLedInit();
  FILE * tc = xFileOpen (PORT, O_RDWR | O_NONBLOCK, &settings);
  stdout = tc;
  stderr = tc;
  stdin = tc;
  sei();

  for (;;) {

    test_count = 1;
    printf_P (PSTR ("\nAvrIO Log test\n"
                    "Press any key to proceed...\n"));
    while (getchar() == EOF)
      ;

    vLogSetMask (LOG_UPTO (LOG_INFO));
    i = iLogMask();
    test (i == LOG_UPTO (LOG_INFO));

    vLog_P (LOG_INFO, flashstr, ++test_count);
    vLog (LOG_INFO, ramstr, ++test_count);

    for (i = LOG_DEBUG; i >= LOG_EMERG; i--) {

      fprintf_P (stderr, PSTR ("\nPriority up to %s\n"), sLogPriorityString(i));
      vLogSetMask (LOG_UPTO (i));
      vLedSet (LED_LED1);
      
      PERROR ("Error %d", test_count++);
      vLedClear (LED_LED1);
      delay_ms (5);
      vLedSet (LED_LED1);
      PWARNING ("Warning %d", test_count++);
      vLedClear (LED_LED1);
      delay_ms (5);
      vLedSet (LED_LED1);
      PNOTICE ("Notice %d", test_count++);
      vLedClear (LED_LED1);
      delay_ms (5);
      vLedSet (LED_LED1);
      PINFO ("Info %d", test_count++);
      vLedClear (LED_LED1);
      PDEBUG ("Debug %d", test_count++);
      PERROR ("Error %d", test_count++);
      PWARNING ("Warning %d", test_count++);
      PNOTICE ("Notice %d", test_count++);
      PINFO ("Info %d", test_count++);
      PDEBUG ("Debug %d", test_count++);
    }

  }
  return 0;
}
Exemplo n.º 2
0
int zion_write_packet(zion_dev_t *dev, zion_packet_t *packet)
{
	volatile u16 write, read;
	volatile u16 d16;
	volatile u32 d32;

	u16 next;
	unsigned long flag;
	zion_packet_t *ptr;

	PRINT_FUNC;

	PASSERT(dev == NULL);
	spin_lock_irqsave(&dev->lock, flag);

	d16 = dev->tx_q.header->read_ptr;
	SWAP16(&read,  &d16);

	d16 = dev->tx_q.header->write_ptr;
	SWAP16(&write, &d16);

//	PINFO("read=%d, write=%d", read, write);

	ptr = dev->tx_q.buffer;
	ptr += write;
	packet->tx_time = zcom_time();
	packet->flags |= ZION_OWNER_SH_FLAG;

	ptr->port  = packet->port;
	ptr->flags = packet->flags;

	SWAP16(&d16, &packet->id);
	ptr->id = d16;

	SWAP32(&d32, &packet->tx_time);
	ptr->tx_time = d32;

	memcpy(ptr->data, packet->data, ZCOM_PACKET_SIZE);

	next  = write + 1;
	if(next >= dev->tx_q.depth){
		next = 0;
	}
	if(read == next){
		PWARNING("TX queue warning");
	}
	SWAP16(&d16, &next);
	dev->tx_q.header->write_ptr=d16;

	spin_unlock_irqrestore(&dev->lock, flag);

#ifdef ZCOM_LOOPBACK
	tasklet_schedule(&loopback_tasklet);
#endif // ZCOM_LOOPBACK

	zion_irq_send(dev);

	return 0;
}
Exemplo n.º 3
0
void __p2pm_do_poff(void)
{
    /* check GPIO port */
    if(!gpio_is_valid_port(param.gpio)){
        PWARNING("can't power-off in order to invalid gpio port=%d\n",param.gpio);
        return;
    }
    PEMERG("power-off by GPIO port = %d\n",param.gpio);
    gpio_set_value(param.gpio,param.pol?1:0);
}
Exemplo n.º 4
0
int __init __p2pm_poff_init(void)
{
    int retval = 0;

    PINFO("initialize is started\n");

    memset(&param,0,sizeof(param));

#ifdef CONFIG_P2PF_PM_POFF_GPIO_OF

    {
        struct device_node *np;
        const u32 *prop;
        u32 len;

        np = of_find_compatible_node(NULL,NULL,compatible);
        if(!np){
            PWARNING("NOT found a node for \"%s\"",compatible);
            goto fail;
        }
        prop = of_get_property(np,"poff",&len);
        len /= sizeof(u32);
        if(!prop||len<2){
            PERROR("NOT found \"poff\" property or too few cells in this property\n");
            retval = -EINVAL;
            goto fail;
        }
        param.gpio = of_get_gpio(np,prop[0]);
        if(param.gpio<0){
            PERROR("NOT foud gpio port\n");
            retval = param.gpio;
            goto fail;
        }
        param.pol = prop[1]?1:0;
    }


#else  /* ! CONFIG_P2PF_PM_POFF_GPIO_OF */

    param.gpio = CONFIG_P2PF_PM_POFF_GPIO_PORT;
#ifdef CONFIG_P2PF_PM_POFF_GPIO_POL_HIGH
    param.pol = 1;
#else  /* ! CONFIG_P2PF_PM_POFF_GPIO_POL_HIGH */
    param.pol = 0;
#endif  /* CONFIG_P2PF_PM_POFF_GPIO_POL_HIGH */

#endif  /* CONFIG_P2PF_PM_POFF_GPIO_OF */

    PINFO("gpio=%d,pol=Active-%s\n",param.gpio,param.pol?"HIGH":"LOW");

 fail:
    return retval;
}