예제 #1
0
파일: main.c 프로젝트: nikkoCheng/gitTest1
void main(void)
{
		//////////////////////
			TMUNUM_INFO xx;
		TMUNUM_INFO  yy;
	///////////////////////////
    unsigned char index;   
		static unsigned char num_byte = 0;
		char y =0;
		EA = 0;
    Soft_WDT_Disnable();

    mcu_f340_init();

    delay_ms(10);

    var_init();
		fmu_cmd_init();
    uart1_init();

#ifdef ID_ONE_WIRE
    one_wire_init( ONE_WIRE_STANDARD_SPEED);
#endif

    delay_ms(10);
    tmu_address_init(); 				    
    EA = 1;     

    WatchDog_Init();

    index = 0;
		countnum = 0;
		port_num = 0;
		
		while(1)
		{		
				xx.c[0] = 2;
				xx.c[1] = 2;
				xx.c[2] = 2;
				xx.c[3] = 2;
				xx.c[4] = 2;
				xx.c[5] = 2;
				write_tmunum_info(&xx);
				read_tmunum_info(&yy);
		}
while(1)
{
	
	char x[10]={1,2,3,4,5,6,7,8,9,10};
	char temp[10];
	int i;
	unsigned char code * data ptrCode;
	x[0] = y++;
	WatchDog();
	earseCodeFlash(TMU_NUM_INFO_ADDR);
	WatchDog();
	writeInnerFlash(TMU_NUM_INFO_ADDR, 10, x);
  ptrCode = (char code *)TMU_NUM_INFO_ADDR;
	for(i = 0;i<10;i++)
	{
		temp[i] = 0;
	}
	for (i = 0; i <10; i++)
	{
		temp[i] = *ptrCode++;
	}
		WatchDog();
}

 while(1)
    { 	
        WatchDog();
        uart_process();

				if(flag30ms)
				{
					/*sssssssssssssssss*/
					flag30ms = 0;
						if(num_byte == 0)
						{
							num_byte = 1;
							read_id(0,0,(unsigned char*)localid_buf);
							WatchDog();
						}
						else
						{
								num_byte = 0;
								read_id(0,1,(unsigned char*)localid_buf);
								WatchDog();
								refresh_current_id();
								memory_clear((unsigned char*)localid_buf,sizeof(localid_buf));
								read_id_96();
						}
				}
					
        if( flag60ms )             
        {
            flag60ms = 0;
            index ++; 
						uart1_timeout();				
					  port_state_process();
            slot_aging_time();	
			
					if(index >= 20)
					{
							index = 0;
							fmu_cmd_update_file_timer_count();
					}
        }
    }
}
예제 #2
0
파일: ds18b20.c 프로젝트: Geliozzz/telemeh
void ds18b20_init(GPIO_TypeDef *gpio, uint16_t port) {
	one_wire_init(gpio, port);
	one_wire_list_of_devices = one_wire_search_rom(&one_wire_devices_list_size);
}
예제 #3
0
파일: hardware.c 프로젝트: nesl/sos-2x
//-------------------------------------------------------------------------
// FUNCTION DECLARATION
//-------------------------------------------------------------------------
void hardware_init(void) {
    init_IO();

    // WATCHDOG SETUP FOR AVR
#ifndef DISABLE_WDT
    /*
     * Hardware Fuse Bit ensures WDT is always ON
     * The following timed sequence sets up a WDT
     * with the longest timeout period.
     */
    __asm__ __volatile__ ("wdr");
    WDTCR = (1 << WDCE) | (1 << WDE);
    WDTCR = (1 << WDE) | (1 << WDP2) | (1 << WDP1) | (1 << WDP0);
#else
    /*
     * WDT may need to be disabled during debugging etc.
     * You must also unset the WDT fuse.  If it is set it
     * is not possible to disable the WDT in software.
     * Setting the fuses to ff9fff will allow it to be disabled.
     */

    __asm__ __volatile__ ("wdr");
    WDTCR = (1 << WDCE) | (1 << WDE);
    WDTCR = 0;
#endif //DISABLE_MICA2_WDT

    // LEDS
    // We do led initialization in sos_watchdog_processing

    // LOCAL TIME
    systime_init();

    // SYSTEM TIMER
    timer_hardware_init(DEFAULT_INTERVAL, DEFAULT_SCALE);

    // UART
#ifdef USE_UART1
    SET_FLASH_SELECT_DD_OUT();
    SET_FLASH_SELECT();
#endif
    uart_system_init();
#ifndef NO_SOS_UART
    //! Initalize uart comm channel
    sos_uart_init();
#endif

    // I2C
    // always initalize the i2c system
    i2c_system_init();
#ifndef NO_SOS_I2C
    //! Initalize i2c comm channel
    sos_i2c_init();
    //! Initialize the I2C Comm Manager
    // Ram - Assuming that it is turned on
    // by default with the SOS_I2C component
    sos_i2c_mgr_init();
#endif

    // ADC
    adc_proc_init();

    // RADIO
#ifndef SOS_EMU
    cc1k_radio_init();
#ifndef DISABLE_RADIO
    cc1k_radio_start();
#ifdef RADIO_XMIT_POWER
    cc1k_cnt_SetRFPower(RADIO_XMIT_POWER);
#endif//RADIO_XMIT_POWER
#else
    cc1k_radio_stop();
#endif//DISABLE_RADIO
#endif//SOS_EMU

    // EXTERNAL FLASH
#ifndef USE_UART1
    exflash_init();
#endif


    // MICA2 PERIPHERALS (Optional)
#ifdef SOS_MICA2_PERIPHERAL
    mica2_peripheral_init();
#endif

    //TODO: We may want to move this out of the mica2 hardware (Roy)
    one_wire_init();

}