Ejemplo n.º 1
0
int
main(int argc, void **argv) {
  int dev, rc, pid_file;

  if (argc < 2) {
    print_usage();
    exit(-1);
  }

  pid_file = open("/var/run/gpiod.pid", O_CREAT | O_RDWR, 0666);
  rc = flock(pid_file, LOCK_EX | LOCK_NB);
  if(rc) {
    if(EWOULDBLOCK == errno) {
      printf("Another gpiod instance is running...\n");
      exit(-1);
    }
  } else {

    init_gpio_pins();

    daemon(0,1);
    openlog("gpiod", LOG_CONS, LOG_DAEMON);
    syslog(LOG_INFO, "gpiod: daemon started");
    run_gpiod(argc, argv);
  }

  return 0;
}
Ejemplo n.º 2
0
void hardware_init(void) {

  /* Enable clock for PORTs */
  SIM_HAL_EnableClock(SIM,kSimClockGatePortA);
  SIM_HAL_EnableClock(SIM,kSimClockGatePortB);

  /* Setup board clock source. */
  g_xtal0ClkFreq = 0U;                  /* System oscillator 0 is not enabled */
  
  init_coredebug_pins(CoreDebug_IDX);
  init_gpio_pins(GPIOA_IDX);
  init_gpio_pins(GPIOB_IDX);
  init_i2c_pins(I2C0_IDX);
  init_rcm_pins(RCM_IDX);
  init_uart0_pins(UART0_IDX);
}
Ejemplo n.º 3
0
void main(void){
  init_general();// Set general runtime configuration bits
  init_gpio_pins(); // Set all I/O pins to low outputs
  init_oscillator(0);// Initialize oscillator configuration bits
  init_timer2();// Initialize timer2 (millis)
  init_adc(NULL); // Initialize ADC module
  init_termination(NOT_TERMINATING);
  init_adcs();// Initialize all of the ADC's
  init_can(); // Initialize CAN

  canAnalogMillis = canDiagMillis = 0;
  ADCCON3bits.GSWTRG = 1; // Initial ADC Conversion?
  STI();// Enable interrupts


  while(1){
    update_analog_channels();
    strain_calc();

    if(millis - canAnalogMillis >= CAN_ANALOG_INTV){
      CANAnalogChannels();
      canAnalogMillis = millis;
    }

    if(millis - canDiagMillis >= CAN_DIAG_INTV){
      CANdiag();
      canDiagMillis = millis;
    }

    sample_temp(); // Sample internal and external temperature sensors

  }
}
Ejemplo n.º 4
0
int main(void){
  init_general();// Set general runtime configuration bits
  init_gpio_pins();// Set all I/O pins to low outputs
  init_oscillator(0);// Initialize oscillator configuration bits
  init_timer2();// Initialize timer2 (millis)

  int i;
  while(1){
    for(i = 0;i<1000000;i++);
    PIC_LED_LAT = 1;
    for(i = 0;i<1000000;i++);
    PIC_LED_LAT = 0;
  }
  return 0;
}