Exemple #1
0
portTASK_FUNCTION(ambilcepat, pvParameters )	{
    vTaskDelay(500);

    int loopambil=0;

#ifdef PAKAI_SHELL
    printf(" Monita : Ambil cepat init !!\r\n");
#endif

#if defined(PAKAI_I2C) && defined(PAKAI_TSC)
    unsigned char st_tsc=0;
    char a;
    int i;
    int c=0;

    if (setup_fma())	printf(" NO ack !\r\n");
    else	{
        printf("Init TSC OK ack !!!\r\n");
        st_tsc = 1;
    }
#endif

#ifdef PAKAI_GPS
    int hasil_gpsnya;
    awal_gps();
#endif

#ifdef PAKAI_ADC
    extern unsigned char status_adcnya;
#endif

#ifdef PAKAI_GPIO_DIMMER
    //init_remang();
#endif

#ifdef PAKAI_PM
    int almtSumber=0;
    int sPM=0;

#ifdef AMBIL_PM
    printf("Init ambil PM ..-ambilcepat-..!!!\r\n");
    vTaskDelay(3000);
#endif
#endif

    int waktunya=0;
    char dataserial[50];

    vTaskDelay(50);
    for(;;) {
        vTaskDelay(1);

#ifdef DATA_RANDOM
        data_f[loopambil%10] = (float) ((rand() % 100));
        //printf("%d: data: %.1f\r\n", loopambil%10, data_f[loopambil%10]);
#endif

        loopambil++;
#ifdef PAKAI_GPS
        if (serPollGPS())
        {
            hasil_gpsnya = proses_gps();
#if 0
            info_gps(hasilGPS);
#endif
        }
#endif

#ifdef PAKAI_PM
#ifdef AMBIL_PM			// AMBIL_PM
        sedot_pm();
#endif
#endif

#ifdef PAKAI_ADC
        if (status_adcnya) {
            proses_data_adc();
            //printf("proses adc ... %d !!\r\n", status_adcnya);

#ifdef BOARD_KOMON_420_SAJA
            hitung_datanya();
#endif

            simpan_ke_data_f();
        }
#endif

#ifdef BOARD_KOMON_KONTER
        if (loopambil%20==0) {		// 5x20 = 100
            hitung_rpm();
        }
        data_frek_rpm();
#endif

#ifdef BOARD_KOMON_KONTER_3_0
        if (loopambil%20==0) {		// 5x20 = 100
            hitung_rpm();
            data_frek_rpm();
        }
#endif

#ifdef PAKAI_I2C
#if 0
        if (st_tsc) {
            if (loopambil%500==0) {	// 2*250: 500ms = 0.5 detik
                printf("__detik: %3d\r\n", c++);
                //baca_register_tsc();

#if 1
                if (int_berganti() == 0)
                {
                    printf("disentuh\r\n");
                }
                else
                    printf("HIGH\r\n");
                //vSerialPutString(0, "HIGH\r\n");
#endif
            }
        }
#endif
#if 0
        if (st_tsc) {
            if (xSerialGetChar(1, &c, 0xFFFF ) == pdTRUE)
            {
                vSerialPutString(0, "Tombol ditekan = ");
                xSerialPutChar(	0, (char ) c);
                vSerialPutString(0, " \r\n");

                if ( (char) c == 's')
                {
                    printf(" Set\r\n");
                    /*
                    if (i2c_set_register(0x68, 1, 8))
                    {
                    	out(" NO ACK !!\r\n");
                    }
                    else
                    	out(" OK\r\n");
                    */

                    if (setup_fma())
                    {
                        printf(" NO ack !\r\n");
                    }
                    else
                        printf(" OK ack !\r\n");


                }
                else
                {
                    printf("====\r\n");
                    for (i=0; i<16; i++)
                    {
                        if (i == 8) printf("****\r\n");

                        if (i2c_read_register(0x68, (0x50 + i), &a))
                        {
                            printf(" Read failed !\r\n");
                        }
                        else
                        {
                            printf(" Read OK =");
                            a = a + '0';
                            printf("%c", (char) a);
                            printf(" \r\n");
                        }
                    }

                    printf("KEY \r\n");
                    if (i2c_read_register(0x68, 0x68, &a))
                    {
                        printf(" Read failed !\r\n");
                    }
                    else
                    {
                        printf(" Read OK =");
                        a = a + '0';
                        printf("%c", (char) a);
                        printf(" \r\n");
                    }
                    //a = read_key();
                    //a = a + '0';
                    //xSerialPutChar(	0, (char ) a);
                }
            }
        }
#endif

#endif


#ifdef PAKAI_GPIO_DIMMER
        //remangkan();
        /*
        loop_pwm++;

        #ifdef DEBUG_PWM_GPIO
        if (loop_pwm>500) {
        	loop_pwm=0;
        	blink_pwm=1-blink_pwm;
        	if (blink_pwm) {
        		FIO1SET = BIT(30);
        	} else {
        		FIO1CLR = BIT(30);
        	}
        }
        #endif
        //*/
#endif
    }

#ifdef PAKAI_GPS
    deinit_gps();
#endif
}
Exemple #2
0
portTASK_FUNCTION(shell, pvParameters )
{
  	int c;
  	xTaskHandle xHandle;
  	printf("\n%s v%s\r\n", NAMA_BOARD, VERSI_KOMON);

  	printf("Daun Biru Engineering, Des 2008\r\n");
  	printf("=========================================\r\n");
  	printf("ARM-GCC %s : %s : %s\r\n", __VERSION__, __DATE__, __TIME__);
  	printf("CPU = LPC 2387, %d MHz,", configCPU_CLOCK_HZ/1000000);
  	printf(" FreeRTOS 5.1.1\r\n");

	if (configUSE_PREEMPTION == 0)
		printf("NON Preemptive kernel digunakan !\r\n"); 
	else
		printf("Preemptive kernel digunakan !\r\n");
	
	#ifdef USB_TEST
	Host_Init();               /* Initialize the lpc2468 host controller                                    */
    //c = Host_EnumDev();       /* Enumerate the device connected */     
   	// if (c == 0) printf("Ketemu !\r\n");  
   	
   	#if 1
   	if (OHCIInit() == 0)
   	{
   		printf("------------ Init error \r\n");
   	}
   	
   	//install_usb_interrupt();
   	#endif
	#endif
	
	/* 
	 * add command
	 */
  	//tinysh_add_command(&myfoocmd);
  	tinysh_add_command(&printenv_cmd);
	tinysh_add_command(&setenv_cmd);
//	tinysh_add_command(&save_env_cmd);
	tinysh_add_command(&reset_cmd);
	tinysh_add_command(&cek_stack_cmd);
	tinysh_add_command(&uptime_cmd);
	tinysh_add_command(&version_cmd);
	
#ifdef BOARD_KOMON_KONTER
	tinysh_add_command(&cek_rpm_cmd);
	tinysh_add_command(&set_kanal_cmd);
#endif

//#ifdef BOARD_TAMPILAN
#ifdef CARI_SUMBER
	tinysh_add_command(&cek_sumber_cmd);
	tinysh_add_command(&set_sumber_cmd);
	//tinysh_add_command(&cek_mesin_cmd);
	//tinysh_add_command(&set_mesin_cmd);
	//tinysh_add_command(&cek_titik_cmd);
	//tinysh_add_command(&set_titik_cmd);
	
	tinysh_add_command(&save_sumber_cmd);
	//tinysh_add_command(&save_mesin_cmd);
	//tinysh_add_command(&save_titik_cmd);
#endif


#ifdef BOARD_KOMON_A_RTD
	tinysh_add_command(&cek_adc_cmd);
	tinysh_add_command(&set_kanal_cmd);
#endif

#ifdef BOARD_KOMON_420_SAJA
#ifdef PAKAI_ADC
	tinysh_add_command(&cek_adc_cmd);
	tinysh_add_command(&lihat_data_cmd);
#endif
	tinysh_add_command(&set_kanal_cmd);
#endif

#ifdef BOARD_KOMON_420_SABANG
#ifdef PAKAI_ADC
	tinysh_add_command(&cek_adc_cmd);
	//tinysh_add_command(&lihat_data_cmd);

	tinysh_add_command(&set_kanal_cmd);
#endif
#endif

#ifdef BOARD_KOMON_B_THERMO
	tinysh_add_command(&cek_adc_cmd);
	tinysh_add_command(&set_kanal_cmd);
#endif

#ifdef PAKE_TELNETD
	tinysh_add_command(&matikan_telnet_cmd);
#endif

#ifdef PAKAI_PM
//	tinysh_add_command(&cek_pm_cmd);
//	tinysh_add_command(&set_pm_cmd);
//	tinysh_add_command(&cek_konfig_pmnya_cmd);
#endif	
	
#ifdef PAKAI_GSM_FTP
	tinysh_add_command(&set_modem_ftp_cmd);
	tinysh_add_command(&cek_modem_cmd);
	tinysh_add_command(&set_modem_gsm_cmd);
	tinysh_add_command(&gsm_ftp_cmd);
	tinysh_add_command(&cek_ftp_cmd);
	
#endif	

#ifdef PAKAI_SMS
	tinysh_add_command(&cek_pulsa_cmd);
	tinysh_add_command(&kirim_sms_cmd);
	tinysh_add_command(&hapus_sms_cmd);
	tinysh_add_command(&baca_sms_cmd);
	tinysh_add_command(&baca_sms_semua_cmd);
	tinysh_add_command(&sms_monita_cmd);
#endif 

#ifdef PAKAI_CRON
	tinysh_add_command(&set_cron_cmd);
	tinysh_add_command(&cek_cron_cmd);
#endif

//#ifdef CARI_SUMBERNYA
#ifdef BOARD_TAMPILAN
	tinysh_add_command(&cek_group_cmd);
	tinysh_add_command(&set_group_cmd);
	
	//tinysh_add_command(&cek_sumber_cmd);
	//tinysh_add_command(&set_sumber_cmd);
	
	// data
	//tinysh_add_command(&set_data_cmd);
	//tinysh_add_command(&cek_data_cmd);
	//printf("board_tampilan\r\n");

#endif
vTaskDelay(100);
#ifdef BANYAK_SUMBER
	tinysh_add_command(&cek_sumber_cmd);
	tinysh_add_command(&set_sumber_cmd);
	tinysh_add_command(&set_data_cmd);
	tinysh_add_command(&cek_data_cmd);
	//printf("banyak sumber\r\n");
#endif
vTaskDelay(100);

#if (VERSI_KONFIGx == 2)
	tinysh_add_command(&cek_group_cmd);
	tinysh_add_command(&set_group_cmd);
	
	tinysh_add_command(&cek_sumber_cmd);
	tinysh_add_command(&set_sumber_cmd);
	
	// data
	tinysh_add_command(&set_data_cmd);
	tinysh_add_command(&cek_data_cmd);
#endif	

// simpan file
#ifdef PAKAI_FILE_SIMPAN	
	tinysh_add_command(&cek_file_cmd);
	tinysh_add_command(&set_file_cmd);
	tinysh_add_command(&del_direktori_cmd);
	tinysh_add_command(&cari_doku_cmd);
	tinysh_add_command(&hapus_filenya_cmd);
#endif


#ifdef CENDOL
	tinysh_add_command(&cek_konfig_cmd);
	tinysh_add_command(&set_konfig_cmd);
#endif

#ifdef PAKAI_MULTI_SERIAL
	#if defined(PAKAI_SERIAL_1) || defined(PAKAI_SERIAL_2) || defined(PAKAI_SERIAL_3)
		tinysh_add_command(&kirim_serial_cmd);
	#endif
#endif
	/* add sub commands
 	*/
  	//tinysh_add_command(&ctxcmd);
  	//tinysh_add_command(&item1);
  	//tinysh_add_command(&item2);

	/* use a command from the stack
 	* !!! this is only possible because the shell will have exited
 	* before the stack of function main !!!
 	*/
  	/*
	{
    	tinysh_cmd_t quitcmd={0,"quit","exit shell",0,reset_to_0,
                          (void *)&again,0,0};
    	tinysh_add_command(&quitcmd);
  	}*/

	/* add atoxi support test command */
  	//tinysh_add_command(&atoxi_cmd);



	/* add a background command */
  	//tinysh_add_command(&bgcmd);
  	//xTaskCreate( bg_cmd_thread, "bg_cmd", 1000, NULL, 2, &xHandle);

	#ifdef PAKAI_MMC
  	vTaskDelay(340);
  	#else
  	vTaskDelay(450);
  	#endif

	#ifdef PAKAI_SELENOID
		static tinysh_cmd_t set_relay_cmd={0,"set_relay","setting relay", "help default ",set_relay,0,0,0};
		tinysh_add_command(&set_relay_cmd);
	#endif
	
	
//#ifdef BOARD_TAMPILAN	
	#ifdef CARI_SUMBERx	
	// cek ukuran struk
	printf("size struct Mesin  = %d\r\n", sizeof (struct t_mesin) * JML_MESIN);
	printf("size struct Sumber = %d\r\n", sizeof (struct t_sumber) * JML_SUMBER);
	printf("size struct Titik  = %d\r\n", sizeof (struct t_titik) * JML_MESIN * TIAP_MESIN);
	//printf("size struct sambungan = %d\r\n", sizeof (samb));
	#endif
	
	#ifdef BOARD_KOMON_420_SAJA
	kalibrasi_adc1();
	vTaskDelay(100);
	start_adc_1();
	#endif
	
	#ifdef BOARD_KOMON_420_SABANG
		#ifdef PAKAI_ADC
			kalibrasi_adc1();
			vTaskDelay(100);
			start_adc_1();
		#endif
		vTaskDelay(100);
	#endif
	
	#ifdef BOARD_KOMON_A_RTD
	kalibrasi_adc1();
	vTaskDelay(100);
	start_adc_1();
	#endif
	
	#ifdef BOARD_KOMON_B_THERMO
	kalibrasi_adc1();
	vTaskDelay(100);
	start_adc_1();
	#endif
	
	#ifdef BOARD_KOMON_KONTER
		#ifdef PAKAI_RTC
		rtc_init();
		vTaskDelay(100);
		//baca_rtc_mem();
		#endif
	#endif
	
	#ifdef PAKAI_MMC
	tinysh_add_command(&util_ls_cmd);
	tinysh_add_command(&util_mkdir_cmd);
	tinysh_add_command(&util_cd_cmd);
	tinysh_add_command(&util_pwd_cmd);
	tinysh_add_command(&util_view_cmd);
	
	init_gpio_mmc();
	uncs_mmc();
	vTaskDelay(5);
	set_fs_mount();
	vTaskDelay(5);
	status_MMC = cek_fs_free();
	
	struct t_simpan_file *ts;
	ts = (char *) ALMT_SFILE;
	vTaskDelay(5);
	
	if (status_MMC) {
		printf("_____MMC ERROR !!!!_____ %d\r\n", status_MMC);
		if (status_MMC==13) 
			printf("_____MMC FR_NO_FILESYSTEM, kudu diformat FAT32 !!!\r\n");
		
		if (ts->set==1) {
			set_file_mati();
			printf("simpan data ke file dimatikan !!\r\n");
		}
	} else {
		status_MMC = 1;
		printf("MMC aktif. Siap simpan data: %d\r\n", status_MMC);
	}
	/*
	FR_NOT_READY,		3 
	FR_NO_FILE,			4 
	FR_NO_PATH,			5 
	FR_INVALID_NAME,	6 
	FR_DENIED,			7 
	FR_EXIST,			8 
	FR_INVALID_OBJECT,	9 
	FR_WRITE_PROTECTED,	10
	FR_INVALID_DRIVE,	11
	FR_NOT_ENABLED,		12
	FR_NO_FILESYSTEM,	13
	FR_MKFS_ABORTED,	14
	FR_TIMEOUT			15
	//*/
	
	
	sprintf(abs_path, "%s", "");
	#endif
	
	#ifdef PAKAI_RTC	
	tinysh_add_command(&set_date_cmd);
	#endif
	
	
	struct t_env *envx;
	envx = (char *) ALMT_ENV;

	sprintf(str,"%s%d$ ", PROMPT, (envx->IP3));
	tinysh_set_prompt(str);
	//tinysh_set_prompt( PROMPT );
	/* force untuk tampil prompt */
	tinysh_char_in('\r');
	int perdetiknya=0;

	/*
	printf("nChr: %d, nInt: %d, nLInt: %d, nFloat: %d, nDouble: %d\r\n", \
		sizeof(char), sizeof(int), sizeof(long int), sizeof(float), sizeof(double));
	printf("nChr: %d, nInt: %d, nLInt: %d, nFloat: %d, nDouble: %d\r\n", \
		255, 20000000, 20000000, 20000000, 20000000);
	//*/
	/*
	 * main loop shell
  	 */
  	int lop = 0;
  	while(1)
    {
		vTaskDelay(1);
	  lop++;
	  if (xSerialGetChar(1, &c, 100 ) == pdTRUE)
	  {
			lop = 0;
			tinysh_char_in((unsigned char)c);
	  }	
	  
	  /* dilindungi password setiap menit tidak ada aktifitas*/
	  if (lop > 6000)
	  {
			lop = 0;
			printf("\r\nPasswd lock!\r\n");
			while(1)
			{
				if (xSerialGetChar(1, &c, 100) == pdTRUE)	{
					if (proses_passwd( &c ) == 1) break;
				}
				#ifdef PAKAI_MMC
					#ifdef PAKAI_FILE_SIMPAN
						perdetiknya++;
						if (perdetiknya==10 && status_MMC==1) {
							proses_simpan_file();
							perdetiknya=0;
						}
					#endif
				#endif
				
				#ifdef PAKAI_ADC
					#ifdef BOARD_KOMON_A_RTD
					proses_data_adc();
					#endif
					 
					#ifdef BOARD_KOMON_B_THERMO
					proses_data_adc();
					#endif
					
					#ifdef BOARD_KOMON_420_SABANG
					proses_data_adc();
					#endif
					
					#ifdef BOARD_KOMON_420_SAJA
					proses_data_adc();
					hitung_datanya();
					#endif
					
					simpan_ke_data_f();
				#endif
				
				#ifdef BOARD_KOMON_KONTER
					data_frek_rpm();
				#endif
			}
	  }
	  
		// pembacaaan ADC dipindah dari task eth ke shell 1 Okt 2010.
		#ifdef PAKAI_ADC
			#ifdef BOARD_KOMON_A_RTD
				proses_data_adc();
			#endif
		 
			#ifdef BOARD_KOMON_B_THERMO
				proses_data_adc();
			#endif
				 
			#ifdef BOARD_KOMON_420_SAJA
				proses_data_adc();
				hitung_datanya();
			#endif
			
			#ifdef BOARD_KOMON_420_SABANG
				proses_data_adc();
			#endif
			
			simpan_ke_data_f();
		#endif
		
		#ifdef BOARD_KOMON_KONTER
			data_frek_rpm();
		#endif
	  
		#ifdef PAKAI_MMC
			#ifdef PAKAI_FILE_SIMPAN
				perdetiknya++;
				if (perdetiknya==10 && status_MMC==1) {
					proses_simpan_file();
					perdetiknya=0;
				}
			#endif
		#endif
	  
	  #ifdef USB_TEST
	  c = HC_INT_STAT ;
	  {
	  	printf("%4d: usb stat 0x%X\r\n", lop, c);
	  	
	  	HC_INT_STAT |= c;
	  	
	  	usb_terup = 0;
	  }
	  #endif
    }
  	
  	return;
}