示例#1
0
static int ui_cmd_showtemp(ui_cmdline_t *cmd,int argc,char *argv[])
{

    temp_smbus_init(TEMPSENSOR_SMBUS_CHAN);

#ifdef _MAX6654_
    do {
	int dev,rev;
	static int didinit = 0;

	if (!didinit) {
	    didinit = 1;
	    dev = temp_smbus_read(TEMPSENSOR_SMBUS_CHAN,TEMPSENSOR_SMBUS_DEV,0xFE);
	    rev = temp_smbus_read(TEMPSENSOR_SMBUS_CHAN,TEMPSENSOR_SMBUS_DEV,0xFF);
	    printf("Temperature Sensor Device ID %02X rev %02X\n",dev,rev);

	    if (dev == 0x4D) {		/* MAX6654 */
		printf("Switching MAX6654 to parasitic mode\n");
		/* Switch to 1hz conversion rate (1 seconds per conversion) */
		temp_smbus_write(TEMPSENSOR_SMBUS_CHAN,TEMPSENSOR_SMBUS_DEV,0x0A,0x04);
		/* Switch to parasitic mode */
		temp_smbus_write(TEMPSENSOR_SMBUS_CHAN,TEMPSENSOR_SMBUS_DEV,9,0x10);
		}
	    }
       } while (0);
#endif    

    if (temp_showtemp(1) < 0) {
	TIMER_CLEAR(temp_timer);
	return -1;
	}

    if (cmd_sw_isset(cmd,"-continuous")) {
	TIMER_SET(temp_timer,2*CFE_HZ);
	}
    if (cmd_sw_isset(cmd,"-stop")) {
	TIMER_CLEAR(temp_timer);
	}

    return 0;
}
示例#2
0
/**
     Initialize the MAC timer.  Called at powerup, or when you
   want to clear all timers.  Sets the timeout for each tick of the
   system clock.
 */
void timerInit(void)
{
    TIMER_INIT();

    // Init the PRNG
    if (NODE_TYPE == ROUTER || NODE_TYPE == COORD)
        srand(TCNT(TICKTIMER));

	TIMER_CLEAR();

    // Enable timer output compare interrupt.  -- Timer starts to interrupt as soon as Global interrup is enabled
    TIMER_ENABLE();
}