예제 #1
0
파일: common.c 프로젝트: friendlyarm/matrix
int writeIntValueToFile(char* fileName, int value) 
{
    clearLastError();
    char buff[50];
    sprintf(buff, "%d", value);
    return writeValueToFile(fileName, buff);
}
예제 #2
0
int 
setPinDirection(unsigned int pin, const char *dir) {
  char fullPath[250];

  sprintf(fullPath, "/sys/class/gpio/gpio%u/direction", pin);
  
  return writeValueToFile(fullPath, dir);
}
예제 #3
0
int 
exportPin(unsigned int pin) {
  char fullPath[250];
  char fullValue[4];

  sprintf(fullPath, "/sys/class/gpio/export");
  sprintf(fullValue, "%u", pin);
  
  return writeValueToFile(fullPath, fullValue);  
}
예제 #4
0
int 
setPinMode(unsigned int pin, unsigned int mode) {
  char fullPath[250];
  char fullValue[4];

  switch(pin) {
  case GPIO1_0:
    sprintf(fullPath, "/sys/kernel/debug/omap_mux/gpmc_ad0");
    break;
  case GPIO1_1:
    sprintf(fullPath, "/sys/kernel/debug/omap_mux/gpmc_ad1");
    break;
  case GPIO1_2:
    sprintf(fullPath, "/sys/kernel/debug/omap_mux/gpmc_ad2");
    break;
  case GPIO1_3:
    sprintf(fullPath, "/sys/kernel/debug/omap_mux/gpmc_ad3");
    break;
  case GPIO1_4:
    sprintf(fullPath, "/sys/kernel/debug/omap_mux/gpmc_ad4");
    break;
  case GPIO1_5:
    sprintf(fullPath, "/sys/kernel/debug/omap_mux/gpmc_ad5");
    break;
  case GPIO1_13:
    sprintf(fullPath, "/sys/kernel/debug/omap_mux/gpmc_ad13");
    break;
  default:
    fprintf(stderr, "Pin not recognized! Please inspect the 'angstrom/setPinMode' function.\n");
    return -1;
    break;
  }

  sprintf(fullValue, "%u", mode);
  
  return writeValueToFile(fullPath, fullValue);  
}