Пример #1
0
// this is called by the eeprom init task
bool eeprom_init_done(semaphore_t *worker_task)
  {
  switch(init_state)
    {
    case config_can :
      if(can_config(memid_nodeid, worker_task))
        init_state = config_serial;
      break;
    case config_serial :
      // TODO: read other config values that are set....
      
      uart_config.rate = get_parameter_type_1(memid_baudrate)->value.SHORT;
      init_deque(&uart_config.rx_queue, RX_BUFFER_LENGTH, rx_queue, NUM_RX_BUFFERS);
  
      init_uart(&uart_config, rx_stack, numelements(rx_stack), tx_stack, numelements(tx_stack));
      
      signal(worker_task);
      init_state = config_complete;
      break;
    default :
      return true;          // init is done
    }
  
  return false;             // more work
  }
Пример #2
0
  {
  .parameter = (can_parameter_definition_t *) &deckb_id_defn,
  .nis.memid = memid_deckb_id,
  .nis.name = "DECKB ID",
  .nis.name_length = 0,
  .nis.parameter_length = sizeof(can_parameter_type_1_t),
  .nis.parameter_type = 1
  },
  };

static ee_definition_t eeprom_definitions[memid_last];

static eeprom_params_t ee_params =
  {
  .worker_stack = eeprom_stack,
  .stack_size = numelements(eeprom_stack),
  .i2c_buffer = i2c_tasks,
  .i2c_queue_len = NUM_I2C_TASKS,
  .i2c_worker_stack = i2c_stack,
  .i2c_worker_stack_length = numelements(i2c_stack),
  .definitions = eeprom_definitions,
  .number_parameters = memid_last,
  };

can_parameter_definition_t *get_parameter(memid_values memid)
  {
  if(memid >= memid_last)
    return 0;
  
  return parameters[memid].parameter;
  }
Пример #3
0
int main(void)
  {
  int8_t idle_task_id;
  
  // set up the ports....
  hw_init();
  // allow input to settle while clock switch in progress
  TRISBbits.TRISB15 = 1;     // input port
  CNPUBbits.CNPUB15 = 1;     // with a pull-up
  
  // set up the PLL for 70Mips
  // FOSC = 10mHz
  // FPLLI = 5Mhz
  // FSYS = 280Mhz
  // FOSC = 140Mhz
  PLLFBD = I_PLLDIV;                      // PLL divider
  CLKDIVbits.PLLPRE = I_PLLPRE;           // Prescaler divide by 2
  CLKDIVbits.PLLPOST = I_PLLPOST;         // Postscale divide by 2
  
  
    // Initiate Clock Switch to Primary Oscillator with PLL (NOSC=0b011)
  if(OSCCONbits.COSC != 0b011)
    {
    __builtin_write_OSCCONH(0x03);
    __builtin_write_OSCCONL(OSCCON | 0x01);
    // Wait for Clock switch to occur
    while (OSCCONbits.COSC!= 0b011);
    }
  // Wait for PLL to lock
  while (OSCCONbits.LOCK!= 1);
 
  // unlock the PPS functions
  __builtin_write_OSCCONL(OSCCON & 0xbf);
    // map pins
  map_rpo(RP42R, rpo_c1tx);
  map_rpi(rpi_rpi44, rpi_c1rx);

  TRISAbits.TRISA0 = 1;
  TRISAbits.TRISA1 = 1;
  TRISAbits.TRISA7 = 1;
  TRISAbits.TRISA10 = 1;
  
  TRISBbits.TRISB0 = 1;
  TRISBbits.TRISB1 = 1;
  TRISBbits.TRISB15 = 1;
  
  TRISCbits.TRISC0 = 1;
  TRISCbits.TRISC1 = 1;
  TRISCbits.TRISC2 = 1;
  
  ee_params.init_mode = PORTBbits.RB15 == 0;
  // set up uart data early
  init_deque(&uart_config.rx_queue, RX_BUFFER_LENGTH, rx_queue, NUM_RX_BUFFERS);
  init_deque(&uart_config.tx_queue, TX_BUFFER_LENGTH, tx_queue, NUM_TX_BUFFERS);
  
  idle_task_id = scheduler_init(tasks, NUM_TASKS, idle_task, idle_stack, numelements(idle_stack));
  resume(idle_task_id);
  
  // create the canbus task
  can_init(HARDWARE_REVISION, SOFTWARE_REVISION,
           can_tx_buffer, CAN_TX_LENGTH,
           can_rx_buffer, CAN_RX_LENGTH,
           can_tx_stack, numelements(can_tx_stack), 0,
           can_rx_stack, numelements(can_rx_stack), 0,
           publisher_stack, numelements(publisher_stack), 0);
  
  subscribe(&listener);

  // initialize the eeprom as we need our settings first
  eeprom_init(&ee_params);
  
  resume(create_task("KEYS", keys_stack, numelements(keys_stack), keys_worker, 0, NORMAL_PRIORITY));
  
  // run with an idle task
  run(idle_task_id);

  return 0;
  }
Пример #4
0
char *ostrcodes[] =
	{
	"bc",	/* Backspace if not "^H" */
	"ko",	/* Termcap entries for other non-function keys */
	"ma",	/* Arrow key map, used by vi version 2 only */
	"nl",	/* Newline character (default "\n") */
	"rs",	/* undocumented reset string, like is (info is2) */
/* Ignore the 'ml' and 'mu' strings. */
	"ml",	/* Memory lock on above cursor. */
	"mu",	/* Memory unlock (turn off memory lock). */
	0
};
int cap_bc = 0, cap_ko = 1, cap_ma = 2, cap_nl = 3, cap_rs = 4;

#define	numelements(x)	(sizeof (x)/sizeof (x[0]))
char oboolval[2][numelements(oboolcodes)];
short onumval[2][numelements(onumcodes)];
char *ostrval[2][numelements(ostrcodes)];

/* externs from libcurses.a */
extern char *boolnames[], *boolcodes[];
extern char *numnames[], *numcodes[];
extern char *strnames[], *strcodes[];

/* globals for this file */
char *progname;			/* argv [0], the name of the program */
static char *term_name;		/* the name of the terminal being worked on */
static int uselevel;		/* whether we're dealing with use= info */
static int boolcount,		/* the maximum numbers of each name array */
	    numcount,
	    strcount;