예제 #1
0
static void doLoad (int argc, char *argv [])
{
  char *module1, *module2 ;
  char cmd [80] ;
  char *file1, *file2 ;
  char args1 [32], args2 [32] ;

  if (argc < 3)
    _doLoadUsage (argv) ;

  args1 [0] = args2 [0] = 0 ;

  /**/ if (strcasecmp (argv [2], "spi") == 0)
  {
    module1 = "spidev" ;
    module2 = "spi_bcm2708" ;
    file1  = "/dev/spidev0.0" ;
    file2  = "/dev/spidev0.1" ;
    if (argc == 4)
      sprintf (args1, " bufsize=%d", atoi (argv [3]) * 1024) ;
    else if (argc > 4)
      _doLoadUsage (argv) ;
  }
  else if (strcasecmp (argv [2], "i2c") == 0)
  {
    module1 = "i2c_dev" ;
    module2 = "i2c_bcm2708" ;
    file1  = "/dev/i2c-0" ;
    file2  = "/dev/i2c-1" ;
    if (argc == 4)
      sprintf (args2, " baudrate=%d", atoi (argv [3]) * 1000) ;
    else if (argc > 4)
      _doLoadUsage (argv) ;
  }
  else
    _doLoadUsage (argv) ;

  if (!moduleLoaded (module1))
  {
    sprintf (cmd, "modprobe %s%s", module1, args1) ;
    system (cmd) ;
  }

  if (!moduleLoaded (module2))
  {
    sprintf (cmd, "modprobe %s%s", module2, args2) ;
    system (cmd) ;
  }

  if (!moduleLoaded (module2))
  {
    fprintf (stderr, "%s: Unable to load %s\n", argv [0], module2) ;
    exit (1) ;
  }

  sleep (1) ;	// To let things get settled

  changeOwner (argv [0], file1) ;
  changeOwner (argv [0], file2) ;
}
예제 #2
0
파일: gpio.c 프로젝트: lolsborn/WiringPi
static void doLoad (int argc, char *argv [])
{
  char *module ;
  char cmd [80] ;
  char *file1, *file2 ;

  if (argc != 3)
    _doLoadUsage (argv) ;

  /**/ if (strcasecmp (argv [2], "spi") == 0)
  {
    module = "spi_bcm2708" ;
    file1  = "/dev/spidev0.0" ;
    file2  = "/dev/spidev0.1" ;
  }
  else if (strcasecmp (argv [2], "i2c") == 0)
  {
    module = "i2c_bcm2708" ;
    file1  = "/dev/i2c-0" ;
    file2  = "/dev/i2c-1" ;
  }
  else
    _doLoadUsage (argv) ;

  if (!moduleLoaded (module))
  {
    sprintf (cmd, "modprobe %s", module) ;
    system (cmd) ;
  }

  if (!moduleLoaded (module))
  {
    fprintf (stderr, "%s: Unable to load %s\n", argv [0], module) ;
    exit (1) ;
  }

  sleep (1) ;	// To let things get settled

  changeOwner (argv [0], file1) ;
  changeOwner (argv [0], file2) ;
}
예제 #3
0
파일: gpio.c 프로젝트: LeMaker/WiringLMK
static void doLoad (int argc, char *argv [])
{
    char *module1, *module2 ;
    char cmd [80] ;
    char *file1, *file2 ;
    char args1 [32], args2 [32] ;

    if (argc < 3)
        _doLoadUsage (argv) ;

    args1 [0] = args2 [0] = 0 ;

    //add for S500
    if(S500_REV == piBoardRev())
    {
        if (strcasecmp (argv [2], "spi") == 0)
        {
            module1 = "spidev" ;
            module2 = "spi-owl" ;
            file1  = "/dev/spidev0.0" ;
            file2  = "/dev/spidev0.1" ;
            if (argc == 4)
                sprintf (args1, " bufsiz=%d", atoi (argv [3]) * 1024) ;
            else if (argc > 4)
                _doLoadUsage (argv) ;
        }
        else if (strcasecmp (argv [2], "i2c") == 0)
        {
            module1 = "i2c_dev" ;
            module2 = "i2c-owl" ;
            file1  = "/dev/i2c-2" ;
            file2  = "/dev/i2c-2" ;
            if (argc == 4)
                sprintf (args2, " baudrate=%d", atoi (argv [3]) * 1000) ;
            else if (argc > 4)
                _doLoadUsage (argv) ;
        }
        else
            _doLoadUsage (argv) ;


        if (!moduleLoaded (module1))
        {
            sprintf (cmd, "  %s%s", module1, args1) ;
            system (cmd) ;
        }


        if (!moduleLoaded (module2))
        {
            sprintf (cmd, "modprobe %s%s", module2, args2) ;
            system (cmd) ;
        }

        if (!moduleLoaded (module2))
        {
            fprintf (stderr, "%s: Unable to load %s\n", argv [0], module2) ;
            exit (1) ;
        }
    }
    /*add for BananaPro by LeMaker team*/
    else if(BP_REV ==  piBoardRev())
    {
        /**/ if (strcasecmp (argv [2], "spi") == 0)
        {
            module1 = "spidev" ;
            module2 = "spi-sun7i" ;
            file1  = "/dev/spidev0.0" ;
            file2  = "/dev/spidev0.1" ;
            if (argc == 4)
                sprintf (args1, " bufsiz=%d", atoi (argv [3]) * 1024) ;
            else if (argc > 4)
                _doLoadUsage (argv) ;
        }
        else if (strcasecmp (argv [2], "i2c") == 0)
        {
            module1 = "i2c_dev" ;
            module2 = "i2c-sunxi" ;
            file1  = "/dev/i2c-2" ;
            file2  = "/dev/i2c-2" ;
            if (argc == 4)
                sprintf (args2, " baudrate=%d", atoi (argv [3]) * 1000) ;
            else if (argc > 4)
                _doLoadUsage (argv) ;
        }
        else
            _doLoadUsage (argv) ;


        if (!moduleLoaded (module1))
        {
            sprintf (cmd, "  %s%s", module1, args1) ;
            system (cmd) ;
        }


        if (!moduleLoaded (module2))
        {
            sprintf (cmd, "modprobe %s%s", module2, args2) ;
            system (cmd) ;
        }

        if (!moduleLoaded (module2))
        {
            fprintf (stderr, "%s: Unable to load %s\n", argv [0], module2) ;
            exit (1) ;
        }
    }
    else
    {

    }
    /*end 2014.08.19*/
    sleep (1) ;	// To let things get settled

    changeOwner (argv [0], file1) ;
    changeOwner (argv [0], file2) ;
}