Exemplo n.º 1
0
PROCESS_THREAD(freakusb_process, ev, data_proc)
{

	PROCESS_POLLHANDLER(freakusb_pollhandler());

	PROCESS_BEGIN();
	usb_init();
	hw_init();
	cdc_init();

	/* TODO: Implement this when we decide to accept commands over the USB */
	cdc_reg_rx_handler(test_avr_usb_rx_handler);

	/* hook the putchar function to the printf and use it for stdout */
	stdout = &file_str;

	/* kick off the polling function */
	process_poll(&freakusb_process);

	while (1) {
		PROCESS_YIELD();
	}

	PROCESS_END();
}
Exemplo n.º 2
0
void main(void)
{
  int cdc_in;
  int uart_in; 
  volatile UINT8 u8Error;
  
  PTBPE_PTBPE5 = 1;                     // DEMOFLEXISJMSD board 
  PTBDD_PTBDD5 = _IN;                     // Initialize Button in 

  hw_init();                            /* MCU Initialization */
  SPI_Init();                           /* SPI Module Init */
  u8Error=SD_Init();                    /* SD Card Init */
  FAT_Read_Master_Block();              /* FAT Driver Init */
  
  cdc_in=uart_in=0xff+1;                /* USB CMX Init */
  usb_cfg_init();
  cdc_init();


  while(PTBD_PTBD5);                    /* Wait until button clic */  
  CDC_Send_String("\r\n\r\n\tSD Card Terminal\r\n");  
  

  while(1)
  {
    cdc_process();                      /* USB CMX CDC process */
    FAT_LS();                           /* Simple function that shows the content*/
    MiniCom();                          /* User Interface call */
  }
}
Exemplo n.º 3
0
int main (int argc, char *argv[])
{
    char *src_filename = NULL;
    int ret = 0, fd_src;
    CDCFileDescriptor file_descr;

    if (argc < 3) {
        fprintf(stderr, "%s SOURCE DEST \n", argv[0]);
        exit(0);
    } else {
        src_filename = argv[1];
        dest_dir = argv[2];
    }

    cdc_init ();
    
    memset (&file_descr, 0, sizeof (file_descr));
    file_descr.write_block = test_write_chunk;
    ret = filename_chunk_cdc (src_filename, &file_descr, NULL, TRUE);
    if (ret == -1) {
        fprintf(stderr, "file chunk failed\n");
        exit(1);
    }

    ret = test_chunks (&file_descr);
    if (ret < 0) {
        fprintf (stderr, "chunk test failed.\n");
        exit(1);
    }

    printf ("test passed.\n");
    return 0;
}
Exemplo n.º 4
0
int main()
{
    usb_init();
    hw_init();

    // init the class driver here
    cdc_init();

    // register the rx handler function with the cdc
    cdc_reg_rx_handler(rx);

    // and off we go...
    while (1)
    {
        usb_poll();
    }
}
Exemplo n.º 5
0
void Comm2PC_Task(void)
{
  CHAR8 c;  
  
  /* configure USB and init CDC driver */
  usb_cfg_init();
  cdc_init();    
  
  /* This loop will receive and process characters from the USB. */
  for(;;)
  {  
    while((*cdc_kbhit)())         
    {
      c=(CHAR8)(*cdc_getch)();
      Comm2PC_FSM(c);
    }
    cdc_process();
    OSSemPend(USB_Sem,0);    
  }  
}
Exemplo n.º 6
0
/****************************************************************************
 ************************** Function definitions ****************************
 ***************************************************************************/
void main(void)
{
  int cdc_in;
  int uart_in;
  
  DC16_Init();
  
  delay_ms(100);
  do_cool_LED_stuff(ALL_ON); // power-on test
  DC16_TX_Test();
  do_cool_LED_stuff(ALL_OFF);
 
  cdc_in=uart_in=0xff+1; // USB CMX init
  cdc_init();
   
  // sorry for this spaghetti-like state machine - i'm just a lowly electrical engineer :)
  while(1)
  {    
    // initialize USB module if it hasn't started yet or has been shutdown
    // this will save power if the USB module isn't needed or used...
    if (!usb_enabled_flag && USB_DETECT)  // when USB plugged in...
    {
      hw_init(); // setup usb & 48MHz clock using 12MHz external crystal (from \USB_CMX\target.c) 
      usb_cfg_init();     
      SPI2BR = 0x11; // SPI baud rate, 3MHz @ 24MHz bus clock
      TPM2SC_PS = 0b010;    // TPM2 timer prescaler = /4
      usb_enabled_flag = 1;
    }
    else if (usb_enabled_flag && !USB_DETECT) // when USB removed, reduce clock speed to 12MHz...
    {
      usb_stop();
      set_clock_12MHz();
      usb_enabled_flag = 0;
    }
  
    if (!SW_MODE) // if button is pressed...
    {
      delay_ms(50); // poor man's debounce
      
      while (!SW_MODE) // while button is held down...
      {
        state_change_flag = 1;
        led_state = ALL_OFF;
      }  
    }
     
    if (state_change_flag) // if there has been a change in state
    {
      if (power_on_flag && usb_enabled_flag && USB_DETECT) // this is only run once at power-on if USB is ready
      {
        power_on_flag = 0;
        Terminal_Send_String("\n\r");
        Terminal_Send_String((unsigned char*)a_word_to_the_wise);
        Terminal_Send_String("\n\r\n\rWelcome to the debug terminal...\n\r\n\r");
      }
      
    	state_change_flag = 0;
  	  switch (state) // ...then set the new state
    	{
    	  case SLEEP:
  	      state = RX;
  	      led_state = KNIGHT_RIDER;
  	      if (usb_enabled_flag && USB_DETECT) Terminal_Send_String("Entering RECEIVE mode.\n\r");
  	      break;
    	  case RX:
    	    state = TX;
    	    led_state = TRANSMIT;
    	    if (usb_enabled_flag && USB_DETECT) Terminal_Send_String("Entering TRANSMIT mode.\n\r");
    	    break;
    	  case TX:
    	  default:
    	    state = SLEEP;
    	    led_state = ALL_OFF;
    	    if (usb_enabled_flag && USB_DETECT) Terminal_Send_String("Going to SLEEP.\n\r");
    	    break;
    	}
    }
    
    switch (state)
    {
      case RX:
        DC16_RX_Mode();
        break;
      case TX:
        DC16_TX_Mode();
        break;
      case SLEEP:   // sleepy time!
      default:
        DC16_Sleep_Mode();
    }
  }
}
Exemplo n.º 7
0
int
main (int argc, char **argv)
{
    int c;
    char *config_dir = DEFAULT_CONFIG_DIR;
    char *seafile_dir = NULL;
    char *central_config_dir = NULL;
    char *logfile = NULL;
    const char *debug_str = NULL;
    int daemon_mode = 1;
    int is_master = 0;
    CcnetClient *client;
    char *ccnet_debug_level_str = "info";
    char *seafile_debug_level_str = "debug";
    int cloud_mode = 0;

#ifdef WIN32
    argv = get_argv_utf8 (&argc);
#endif

    while ((c = getopt_long (argc, argv, short_options, 
                             long_options, NULL)) != EOF)
    {
        switch (c) {
        case 'h':
            exit (1);
            break;
        case 'v':
            exit (1);
            break;
        case 'c':
            config_dir = optarg;
            break;
        case 'd':
            seafile_dir = g_strdup(optarg);
            break;
        case 'F':
            central_config_dir = g_strdup(optarg);
            break;
        case 'f':
            daemon_mode = 0;
            break;
        case 'l':
            logfile = g_strdup(optarg);
            break;
        case 'D':
            debug_str = optarg;
            break;
        case 'g':
            ccnet_debug_level_str = optarg;
            break;
        case 'G':
            seafile_debug_level_str = optarg;
            break;
        case 'm':
            is_master = 1;
            break;
        case 'P':
            pidfile = optarg;
            break;
        case 'C':
            cloud_mode = 1;
            break;
        default:
            usage ();
            exit (1);
        }
    }

    argc -= optind;
    argv += optind;

#ifndef WIN32
    if (daemon_mode) {
#ifndef __APPLE__
        daemon (1, 0);
#else   /* __APPLE */
        /* daemon is deprecated under APPLE
         * use fork() instead
         * */
        switch (fork ()) {
          case -1:
              seaf_warning ("Failed to daemonize");
              exit (-1);
              break;
          case 0:
              /* all good*/
              break;
          default:
              /* kill origin process */
              exit (0);
        }
#endif  /* __APPLE */
    }
#endif /* !WIN32 */

    cdc_init ();

#if !GLIB_CHECK_VERSION(2, 35, 0)
    g_type_init();
#endif
#if !GLIB_CHECK_VERSION(2,32,0)
    g_thread_init (NULL);
#endif

    if (!debug_str)
        debug_str = g_getenv("SEAFILE_DEBUG");
    seafile_debug_set_flags_string (debug_str);

    if (seafile_dir == NULL)
        seafile_dir = g_build_filename (config_dir, "seafile", NULL);
    if (logfile == NULL)
        logfile = g_build_filename (seafile_dir, "seafile.log", NULL);

    if (seafile_log_init (logfile, ccnet_debug_level_str,
                          seafile_debug_level_str) < 0) {
        seaf_warning ("Failed to init log.\n");
        exit (1);
    }

    client = ccnet_init (central_config_dir, config_dir);
    if (!client)
        exit (1);

    register_processors (client);

    start_rpc_service (client, cloud_mode);

    create_sync_rpc_clients (central_config_dir, config_dir);
    create_async_rpc_clients (client);

    seaf = seafile_session_new (central_config_dir, seafile_dir, client);
    if (!seaf) {
        seaf_warning ("Failed to create seafile session.\n");
        exit (1);
    }
    seaf->is_master = is_master;
    seaf->ccnetrpc_client = ccnetrpc_client;
    seaf->async_ccnetrpc_client = async_ccnetrpc_client;
    seaf->ccnetrpc_client_t = ccnetrpc_client_t;
    seaf->async_ccnetrpc_client_t = async_ccnetrpc_client_t;
    seaf->client_pool = ccnet_client_pool_new (central_config_dir, config_dir);
    seaf->cloud_mode = cloud_mode;

    load_history_config ();

    g_free (seafile_dir);
    g_free (logfile);

    set_signal_handlers (seaf);

    /* init seaf */
    if (seafile_session_init (seaf) < 0)
        exit (1);

    if (seafile_session_start (seaf) < 0)
        exit (1);

    if (pidfile) {
        if (write_pidfile (pidfile) < 0) {
            ccnet_message ("Failed to write pidfile\n");
            return -1;
        }
    }
    atexit (on_seaf_server_exit);

    /* Create a system default repo to contain the tutorial file. */
    schedule_create_system_default_repo (seaf);

    ccnet_main (client);

    return 0;
}
Exemplo n.º 8
0
int
main (int argc, char **argv)
{
    int c;
    char *config_dir = DEFAULT_CONFIG_DIR;
    char *seafile_dir = NULL;
    char *worktree_dir = NULL;
    char *logfile = NULL;
    const char *debug_str = NULL;
    int daemon_mode = 0;
    CcnetClient *client;
    char *ccnet_debug_level_str = "info";
    char *seafile_debug_level_str = "debug";

#ifdef WIN32
    LoadLibraryA ("exchndl.dll");

    argv = get_argv_utf8 (&argc);
#endif

    while ((c = getopt_long (argc, argv, short_options, 
                             long_options, NULL)) != EOF)
    {
        switch (c) {
        case 'h':
            usage();
            exit (1);
            break;
        case 'v':
            exit (1);
            break;
        case 'c':
            config_dir = optarg;
            break;
        case 'd':
            seafile_dir = g_strdup(optarg);
            break;
        case 'b':
            daemon_mode = 1;
            break;
        case 'D':
            debug_str = optarg;
            break;
        case 'w':
            worktree_dir = g_strdup(optarg);
            break;
        case 'l':
            logfile = g_strdup(optarg);
            break;
        case 'g':
            ccnet_debug_level_str = optarg;
            break;
        case 'G':
            seafile_debug_level_str = optarg;
            break;
        default:
            usage ();
            exit (1);
        }
    }

    argc -= optind;
    argv += optind;

#ifndef WIN32
    if (daemon_mode) {
#ifndef __APPLE__
        daemon (1, 0);
#else   /* __APPLE */
        /* daemon is deprecated under APPLE
         * use fork() instead
         * */
        switch (fork ()) {
          case -1:
              seaf_warning ("Failed to daemonize");
              exit (-1);
              break;
          case 0:
              /* all good*/
              break;
          default:
              /* kill origin process */
              exit (0);
        }
#endif  /* __APPLE */
    }
#endif /* !WIN32 */

    cdc_init ();

#if !GLIB_CHECK_VERSION(2, 35, 0)
    g_type_init();
#endif
#if !GLIB_CHECK_VERSION(2, 31, 0)
    g_thread_init(NULL);
#endif

    if (!debug_str)
        debug_str = g_getenv("SEAFILE_DEBUG");
    seafile_debug_set_flags_string (debug_str);

    if (logfile == NULL)
        logfile = g_build_filename (config_dir, "logs", "seafile.log", NULL);
    if (seafile_log_init (logfile, ccnet_debug_level_str,
                          seafile_debug_level_str) < 0) {
        seaf_warning ("Failed to init log.\n");
        exit (1);
    }

    if (!bind_ccnet_service (config_dir)) {
        seaf_warning ("Failed to bind ccnet service\n");
        exit (1);
    }

    /* init ccnet */
    client = ccnet_init (config_dir);
    if (!client)
        exit (1);

    start_rpc_service (client);

    create_sync_rpc_clients (config_dir);
    appletrpc_client = ccnet_create_async_rpc_client (client, NULL, 
                                                      "applet-rpcserver");

    /* init seafile */
    if (seafile_dir == NULL)
        seafile_dir = g_build_filename (config_dir, "seafile-data", NULL);
    if (worktree_dir == NULL)
        worktree_dir = g_build_filename (g_get_home_dir(), "seafile", NULL);

    seaf = seafile_session_new (seafile_dir, worktree_dir, client);
    if (!seaf) {
        seaf_warning ("Failed to create seafile session.\n");
        exit (1);
    }
    seaf->ccnetrpc_client = ccnetrpc_client;
    seaf->appletrpc_client = appletrpc_client;

    seaf_message ("starting seafile client "SEAFILE_CLIENT_VERSION"\n");
#if defined(SEAFILE_SOURCE_COMMIT_ID)
    seaf_message ("seafile source code version "SEAFILE_SOURCE_COMMIT_ID"\n");
#endif

    g_free (seafile_dir);
    g_free (worktree_dir);
    g_free (logfile);

    set_signal_handlers (seaf);

    seafile_session_prepare (seaf);
    seafile_session_start (seaf);

    seafile_session_config_set_string (seaf, "wktree", seaf->worktree_dir);
    ccnet_main (client);

    return 0;
}
Exemplo n.º 9
0
static void
init_ezport(int config)
{
        cdc_init(NULL, NULL, &cdc);
}
Exemplo n.º 10
0
int
main (int argc, char **argv)
{
    int c;
    char *config_dir = DEFAULT_CONFIG_DIR;
    char *seafile_dir = NULL;
    char *logfile = NULL;
    const char *debug_str = NULL;
    int daemon_mode = 1;
    int is_master = 0;
    CcnetClient *client;
    char *ccnet_debug_level_str = "info";
    char *seafile_debug_level_str = "debug";
    int cloud_mode = 0;

#ifdef WIN32
    LoadLibraryA ("exchndl.dll");

    argv = get_argv_utf8 (&argc);
#endif

    while ((c = getopt_long (argc, argv, short_options, 
                             long_options, NULL)) != EOF)
    {
        switch (c) {
        case 'h':
            exit (1);
            break;
        case 'v':
            exit (1);
            break;
        case 'c':
            config_dir = optarg;
            break;
        case 'd':
            seafile_dir = g_strdup(optarg);
            break;
        case 'f':
            daemon_mode = 0;
            break;
        case 'l':
            logfile = g_strdup(optarg);
            break;
        case 'D':
            debug_str = optarg;
            break;
        case 'g':
            ccnet_debug_level_str = optarg;
            break;
        case 'G':
            seafile_debug_level_str = optarg;
            break;
        case 'm':
            is_master = 1;
        case 'P':
            pidfile = optarg;
            break;
        case 'C':
            cloud_mode = 1;
            break;
        default:
            usage ();
            exit (1);
        }
    }

    argc -= optind;
    argv += optind;

#ifndef WIN32
    if (daemon_mode)
        daemon (1, 0);
#endif

    cdc_init ();

    g_type_init ();
#if !GLIB_CHECK_VERSION(2,32,0)
    g_thread_init (NULL);
#endif

    if (!debug_str)
        debug_str = g_getenv("SEAFILE_DEBUG");
    seafile_debug_set_flags_string (debug_str);

    if (seafile_dir == NULL)
        seafile_dir = g_build_filename (config_dir, "seafile", NULL);
    if (logfile == NULL)
        logfile = g_build_filename (seafile_dir, "seafile.log", NULL);

    if (seafile_log_init (logfile, ccnet_debug_level_str,
                          seafile_debug_level_str) < 0) {
        seaf_warning ("Failed to init log.\n");
        exit (1);
    }

    client = ccnet_init (config_dir);
    if (!client)
        exit (1);

    register_processors (client);

    start_rpc_service (client, cloud_mode);

    create_sync_rpc_clients (config_dir);
    create_async_rpc_clients (client);

    seaf = seafile_session_new (seafile_dir, client);
    if (!seaf) {
        seaf_warning ("Failed to create seafile session.\n");
        exit (1);
    }
    seaf->is_master = is_master;
    seaf->ccnetrpc_client = ccnetrpc_client;
    seaf->async_ccnetrpc_client = async_ccnetrpc_client;
    seaf->ccnetrpc_client_t = ccnetrpc_client_t;
    seaf->async_ccnetrpc_client_t = async_ccnetrpc_client_t;
    seaf->client_pool = ccnet_client_pool_new (config_dir);
    seaf->cloud_mode = cloud_mode;

    load_history_config ();

    g_free (seafile_dir);
    g_free (logfile);

    set_signal_handlers (seaf);

    /* init seaf */
    if (seafile_session_init (seaf) < 0)
        exit (1);

    if (seafile_session_start (seaf) < 0)
        exit (1);

    if (pidfile) {
        if (write_pidfile (pidfile) < 0) {
            ccnet_message ("Failed to write pidfile\n");
            return -1;
        }
    }
    atexit (on_seaf_server_exit);

    ccnet_main (client);

    return 0;
}
Exemplo n.º 11
0
static void
init_vcdc(int config)
{
        cdc_init(new_data, NULL, &cdc);
}
Exemplo n.º 12
0
void
init_cdc(int config)
{
        cdc_init(new_data, space_available, &cdc);
}