Beispiel #1
0
int main( void )
{
    WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
    BCSCTL1=0x00; //&= ~XT2OFF; // XT2= HF XTAL
    do{
      IFG1 &= ~OFIFG; // Clear OSCFault flag
      for (int i = 0xFF; i > 0; i--); // Time for flag to set
    }while ((IFG1 & OFIFG)); // OSCFault flag still set?
    BCSCTL2 |= SELM_2+SELS; // MCLK=SMCLK=XT2 (safe)

//Init System Service    
    InitialPort();
    InitFileSystem();
    Init_Pipe();
    InitTB();
//Init Device    
    InitialRTC();        
    Init_UART();
    InitADC();
    Creat_Command_Task();                   //After the bluetooth has beed connected
    SCH_Init();
   SCH_Start();

//    SCH_Add_Task(Task_UART_Send,0,5);       //creat a task for sending data via uart,after bluetooth connect
//   SCH_Add_Task(Acquire_ECG,0,4);      //32768/4*32 = 256hz
//    CommandSwitchList(1);

    while(1){
        SCH_Dispatch_Task();
    }
}
void main()
{  TRISB=0x00;
   TRISA=0x00;
   TRISDbits.TRISD7=0; // chan dieu khien coi bao
   
   a=0;
   index=0x03; 
   Init_UART();
   Init_Tran_UART();
   Init_Rec_UART();
 
   Osc();
   Pwm_init();
  
   VITRI=VITRI_3;
   //putrsUSART ((const far rom char*)"\r\nNguy hiem muc 3\r\n");
	

	while(1)
	{
    LATAbits.LATA0= (index );// lay 4 bit chua gia tri cua index truyen sang 7447, tranh chan ngat int0
    LATBbits.LATB1= (index >>1);
    LATBbits.LATB2= (index >>2);
    LATBbits.LATB3= (index >>3);
    LATDbits.LATD7= a;
    SetDCPWM2(VITRI);
    }
    while(1);
}
Beispiel #3
0
void InitIO(void)
{
	//Init UART for debug
	//If USB is plugged
	//TTL232R-3V3-WE will pull _RF3 and _RF5 high
	if(_RF2==1 && _RF3==1);
	{
		//Connect RP99 to U1TX
		_RP98R =	0b000001;
		//Init Uart and connect RP104 to U1RX 	
		Init_UART((unsigned int)(FOSC/BAUDRATE/32.0f)-1,99);
	}

        /*Set ports to digital*/
	ANSELA = ANSELB = ANSELC = ANSELD = ANSELE = ANSELG = 0x0000;

        /*Set inputs and outputs*/
	TRISE=0x0000;
        TRISC=0x0000;
	TRISF=0x0000;
	TRISD=0x0000;
	TRISG=0x0000;
        TRISA=0x0000;
        TRISDbits.TRISD1 = 0;   //Output for CAN
        TRISDbits.TRISD2 = 1;   //Input for CAN
	TRISB=0xFFFF;           //Analog inputs

        /*Reset leds*/
        LED0=0;
        LED1=0;

}
Beispiel #4
0
int main(){
    Init_UART();
    Init_BT();
    Init_Default_Led();
    Init_WU();

    SystemInit();
    if(SysTick_Config(SystemCoreClock / 1000)){
       while(1);
    }

    char str[256];
    sprintf(str,"\n\nFlash Size : %dKb\nUID : %X%X%X\n",*(volatile u16*)(0x1FFFF7E0),
   *(volatile u32*)(0x1FFFF7E8),*(volatile u32*)(0x1FFFF7EC),*(volatile u32*)(0x1FFFF7F0));
    USART1_Send_Sting(str);
    BT_Send_String(str);

    while(1){
       GPIO_SetBits(GPIOC,GPIO_Pin_13);
       Delay(1000);
       GPIO_ResetBits(GPIOC,GPIO_Pin_13);

       PWR_StandbyMode();
    }
}
int main(void){
    volatile unsigned char a[100]="Laboratory #2 for EEL4742 Embedded Systems0";//string to print
    volatile unsigned char b;
    volatile unsigned int i=0; // index of string
    WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
    Init_UART();
    while(i>=0){//loop until entire string is printed
        b=a[i];//temp variable to hold character
        
        if(a[i]=='0'){//if null character is found, break loop
            break;//break statement
        }
        OUTA_UART(b);//display character in hyperterminal
        i++;//increment index
    }
    // go blink the light to indicate code is running
    P2DIR |= 0x02; // Set P1.0 to output direction
    // Use The LED as an indicator
    for (;;){
        P2OUT ^= 0x02; // Toggle P1.0 using exclusive-OR
        i = 10000; // SW Delay
        do i--;
        while (i != 0);
    }
}
Beispiel #6
0
void initialisation_UART(void){

	/* Initialisation de l'UART, à mettre après l'initialisation du PIC  */
	//FOSC is the frequency of the CPU clock
	_RP85R =	0b000001;									//Connect RP85  to U1TX
	Init_UART((unsigned int)(FOSC/BAUDRATE/32.0f)-1,87);	//Connect RP87 to U1RX
}
Beispiel #7
0
int main(void) 
{
  WDTCTL   = WDTPW + WDTHOLD                         ;
  Init_CLK()                                         ;
  Init_J60SPI()                                      ;
  MAIN_POWER_ON                                      ;
  __delay_cycles(5000000)                            ;
  P9DIR   |= IrDA_OUT                                ;
  P9OUT   &=~IrDA_OUT                                ;
  Init_EtherNet()                                    ;
  ENC_SLEEP()                                        ; // 省电  
    
  OS_IncDI()                                         ; // 屏蔽中断
  OS_InitKern()                                      ; // 初始化系统内核
  OS_InitHW()                                        ; // 初始化硬件
  Init_Func()                                        ;
  Init_UART()                                        ;  
  Init_RSUART()                                      ;
  Ini_LED(8)                                         ;
  Init_ADC()                                         ;
  Init_RTC()                                         ;
  LCD_Init()                                         ;

  LED_POWER_ON                                       ;
  BackLight()                                        ;
  OS_CREATERSEMA(&SemaLCD)                           ;
  OS_CREATERSEMA(&SemaSPI)                           ;
  LED_Disp_Float(3.1415925,7,FIT_ZERO)               ;
  LED_Flicker_Digit(8,1)                             ;  
  Color     = Black                                  ;
  Color_BK  = 0xEF9F                                 ;
  
  OS_CREATETASK(&Seg7LED_TASK_TCB, 
                "Seg7LedTask", 
                Seg7LedRefresh, 100, 
                Seg7LED_TASK_STACK  )                ;
  
  OS_CREATETASK(&LCD_TASK_TCB, 
                "LCD_Task", 
                LCD_Task, 100, 
                LCD_TASK_STACK  )                    ;
  
  OS_CREATETASK(&MENU_OP_TASK_TCB, 
                "MENU_OP_Task", 
                MENU_OP_Task, 100, 
                MENU_OP_TASK_STACK)                  ;

  OS_CREATETASK(&KEY_TP_TASK_TCB, 
                "KEY_TP_Task", 
                Key_TP_Task, 100, 
                KEY_TP_TASK_STACK  )                 ;
  
  
  OS_Start()                                         ; 
  return 0                                           ;
}
Beispiel #8
0
/*****************************************************************************
 main()
 
 No introduction needed ... 
 ****************************************************************************/
void main(void) {
    Init_hardware();
    Init_UART();
    
    while (1) {
        uint8_t b;
        b = UART_read_byte();
        b = filter(b);
        UART_send(b);
    }
}
Beispiel #9
0
int main(void) {
//  SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN| SYSCTL_XTAL_8MHZ);
	SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
	GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_0);

	Init_ADC();
	Init_PWM();
	Init_Timer();
	Init_UART();
	while (1) {

	}
}
Beispiel #10
0
void main()
{
    OSCCONbits.IRCF = 0b011;//1 MHz

    TRISB = 0x00;
    TRISA = 0x00;
    TRISDbits.TRISD7 = 0; // chan dieu khien coi bao

    alarm = 0;

    Led7 = 0x03;
    Init_UART();
//    Init_Tran_UART();
//    Init_Rec_UART();

    //initialize UART module
//    OpenUSART(USART_TX_INT_OFF &
//            USART_RX_INT_ON &
//            USART_ASYNCH_MODE &
//            USART_EIGHT_BIT &
//            USART_BRGH_HIGH &
//            BAUD_16_BIT_RATE,
//            12);

    INTCONbits.PEIE = 1;//Peripheral interrupt enable
    INTCONbits.GIE = 1; // Golbal interrupt enable
    Pwm_init();

    VITRI = VITRI_3;

    while(1)
    {
        LATAbits.LATA0 = Led7;// lay 4 bit chua gia tri cua Led7 truyen sang 7447, tranh chan ngat int0
        LATBbits.LATB1 = (Led7 >>1);
        LATBbits.LATB2 = (Led7 >>2);
        LATBbits.LATB3 = (Led7 >>3);
        LATDbits.LATD7 = alarm;

        SetDCPWM2(VITRI);

        if(EnableProcess)
        {
            Processing();
            EnableProcess = 0;
        }
    }
    //while(1);
}
Beispiel #11
0
int main(void) {

  //SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN| SYSCTL_XTAL_8MHZ);	//8MHz
	SysCtlClockSet(
			SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN
					| SYSCTL_XTAL_8MHZ); //20MHz
	//SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);  //50Mhz

	Init_GPIO();

	Init_UART();

	while (1) {

	}
}
Beispiel #12
0
static void InitializeSystem(void) {
    ADCON1 |= 0x0F;
//    TRISCbits.TRISC6=0;
//    TRISCbits.TRISC7 =0;
//    LATCbits.LATC6 =0;
//    LATCbits.LATC7=0;
    USBDeviceInit();
#if defined(USE_UART)
    Init_UART(BAUD_RATE);
    Init_Tran_UART();
    Init_Rec_UART();
#endif
#if defined(USE_LCD)
    Init_PORTS();
    Init_LCD();
#endif
}
Beispiel #13
0
/**
 * @brief función de inicialización de hardware. Inicializa pines y Timmer
 *
 */
void bsp_Init(void){
	WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    DCOCTL = CALDCO_1MHZ;       //seteo clock a 1MHZ
    BCSCTL1 = CALBC1_1MHZ;

    //inicialización pines
    LedRojo = (void*)hal_pin_init(&pinLedRojo); //hal_pin_init() carga en registros del micro lo establecido en la estructura
    LedVerde = (void*)hal_pin_init(&pinLedVerde);
	Sw = (void*)hal_pin_init(&pinSw);
	Led1 = (void*)hal_pin_init(&pinLed1);
	Led2 = (void*)hal_pin_init(&pinLed2);

	Sw1 = (void*)hal_pin_init(&pinSw1);
	Sw2 = (void*)hal_pin_init(&pinSw2);
	Sw3 = (void*)hal_pin_init(&pinSw3);
	Sw4 = (void*)hal_pin_init(&pinSw4);


	hal_pin_init(&cc_gdo0);
	hal_pin_init(&cc_gdo2);
	hal_pin_init(&cc_spiSOMI);
	hal_pin_init(&cc_spiSIMO);
	hal_pin_init(&cc_spiCLK);
	hal_pin_init(&cc_spinCS);

	//inicialización SPI
	spi1_setup((uint8_t*)&UCB0CTL0);

	//inicialización CC2500
	hal_cc2500_powerupReset();
	hal_cc2500_WriteRFSettings();

	//inicialización Timmer
    TACTL = (TASSEL_2 + ID_0 + MC_2);
    TACCTL1 = (CM_0 + CCIS_2);
    TACCR1 = TAR + 1000;
    TACCTL1 &= ~(CCIFG);
    TACCTL1 |= CCIE;

    Init_UART();                                // Inicialize USCIA (UART Mode)

	__enable_interrupt();

}
void main(void) {
	
	WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
	
	if (CALBC1_16MHZ ==0xFF || CALDCO_16MHZ == 0xFF) while(1);
	                                             
	DCOCTL = CALDCO_16MHZ;    // Set uC to run at approximately 16 Mhz
	BCSCTL1 = CALBC1_16MHZ; 
	
	// Initialize Port 1
	P1SEL &= ~0x01;  // See page 42 and 43 of the G2553's datasheet, It shows that when both P1SEL and P1SEL2 bits are zero   
	P1SEL2 &= ~0x01; // the corresponding pin is set as a I/O pin.  Datasheet: http://coecsl.ece.illinois.edu/ge423/datasheets/MSP430Ref_Guides/msp430g2553datasheet.pdf  
	P1REN = 0x0;  // No resistors enabled for Port 1
	P1DIR |= 0x1; // Set P1.0 to output to drive LED on LaunchPad board.  Make sure shunt jumper is in place at LaunchPad's Red LED
	P1OUT &= ~0x01;  // Initially set P1.0 to 0
	
	
	// Timer A Config
	TACCTL0 = CCIE;       		// Enable Periodic interrupt
	TACCR0 = 16000;                // period = 1ms   
	TACTL = TASSEL_2 + MC_1; // source SMCLK, up mode
	
	
	Init_UART(9600,1);	// Initialize UART for 9600 baud serial communication

	_BIS_SR(GIE); 		// Enable global interrupt

	
	while(1) {

		if(newmsg) {
			newmsg = 0;
		}

		if (newprint)  {
		 
			P1OUT ^= 0x1;		// Blink LED
					
			UART_printf("Hello %d\n\r",(int)(timecnt/500));

			newprint = 0;
		}

	}
}
Beispiel #15
0
	int main(void){
		volatile unsigned char a;
		volatile unsigned int i; 	// volatile to prevent optimization
		WDTCTL = WDTPW + WDTHOLD; 	// Stop watchdog timer
		Init_UART();

		// Make green and yellow outputs
		P2DIR |= 0x06; 	// Set P1.0 to output direction
						// Use The LED as an indicator



		P2OUT = 0x00; 		//Start with Green and Yellow LEDs off

		for (;;)			//Run for ever
			toogleLED();

}
Beispiel #16
0
int main(void)
{
	BTNDIS_P();
	Init_EMIF();
	Init_LEDS();
	Init_TIMER();
	Init_FPGA();
	Init_UART();
	Init_TWI(100000);
	
	mbootBanner();
	
	Init_RTC();
	Init_Media();
	Init_SHA204();
	Init_EMAC();
	SYS_UNRESET();
	
	mboot();

	while(1);
	// return 0;
}
int main(void){
    volatile unsigned char a;
    volatile unsigned int i=1; // volatile to prevent optimization
    WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
    //initalized UART communication with MSP430 to hyperterminal
    Init_UART();
    
    while(i!=0){
        a=INCHAR_UART();//function that reads character from keyboard
        if(a=='0x00'){//if character enter is null, break loop
            break;
        }
        OUTA_UART(a);//display character in hyperterminal
    }
    // go blink the light to indicate code is running
    P2DIR |= 0x02; // Set P1.0 to output direction
    // Use The LED as an indicator
    for (;;){
        P2OUT ^= 0x02; // Toggle P1.0 using exclusive-OR
        i = 10000; // SW Delay
        do i--;
        while (i != 0);
    }
}
 int main(void){
volatile unsigned char d;
volatile unsigned int i, j[20], x[5], temp[3]; // volatile to prevent optimization
volatile unsigned int a, b, c, e;

WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

P2DIR |= 0x02; // Set P1.0 to output direction

Init_UART();
Init_LCD();

j[0] = 0x5F;
j[1] = 0X06;
j[2] = 0X6B;
j[3] = 0X2F;
j[4] = 0X36;
j[5] = 0X3D;
j[6] = 0X7D;
j[7] = 0X07;
j[8] = 0X7F;
j[9] = 0X37;
j[10] = 0X77;
j[11] = 0X7C;
j[12] = 0X68;
j[13] = 0X6E;
j[14] = 0X79;
j[15] = 0X71;



for (;;){

//letter input 1
				a=INCHAR_UART();
				OUTA_UART(a);

//Check if it's a digit or a character and transform to binary
				if((a>=0x30) && (a<=0x39)){
					a = a-0x30;
				}
				else{
					a = a-0x37;
				}

//letter input 2
				b=INCHAR_UART();
				OUTA_UART(b);


//Check if it's a digit or a character and transform to binary
				if((b>=0x30) && (b<=0x39)){
					b = b-0x30;
				}
				else{
					b = b-0x37;
				}


//Multiply a by 16 because of Hex, add together to obtain final number
				temp[1] = (a*16)+(b);
	
				d=INCHAR_UART();
				OUTA_UART(d);

//letter input 3
				a=INCHAR_UART();
				OUTA_UART(a);
//letter input 4
				b=INCHAR_UART();
				OUTA_UART(b);
				OUTA_UART(0x3D);


//Repeat procedure for the next two characters
				if((a>=0x30) && (a<=0x39)){
					a = a-0x30;
					}
				else{
					a = a-0x37;
				}

				if((b>=0x30) && (b<=0x39)){
					b = b-0x30;
				}
				else{
					b = b-0x37;
				}


//Multiply a by 16 because of Hex, add together to obtain final number
				temp[2] = (a*16)+(b);
				
//If both numbers are equal
				if(temp[1]==temp[2]){
					e = 0;
					LCDSeg[2]=0x00;
				}


//If the first number is bigger simply subtract
				else if(temp[1]>temp[2]){
				e = temp[1]-temp[2];
				LCDSeg[2]=0x00; //reset LCD
				}
				
//If second number is bigger, invert numbers and add (-) before answer
				else{
					e=temp[2]-temp[1];
					OUTA_UART(0X2D);
					LCDSeg[2]=0x20;
				}

//The next three steps will yield the digits we'll print onto the LCD
				if((e/16)>15){
					x[3] =1;
					x[2]=(e/16)-16;
				}
				else{
					x[3]=0;
					x[2]=e/16;
				}

				x[1]= e%16;

//Print on LCD
				LCDSeg[1] = j[x[2]];
				LCDSeg[0] = j[x[1]];

//Convert our decimal characters back to ascii
				if(x[3]<=9)
					x[3]=x[3] + 0x30;
				else
					x[3]=x[3] + 0x37;

				if(x[2]<=9)
					x[2]=x[2] + 0x30;
				else
					x[2]=x[2] + 0x37;

				if(x[1]<=9)
					x[1]=x[1] + 0x30;
				else
					x[1]=x[1] + 0x37;


//print the characters onto the Hyperterminal
				OUTA_UART(x[2]);
				OUTA_UART(x[1]);
//Print New line
				OUTA_UART(0X0A);
				OUTA_UART(0X0D);


}
}
/*********主函数**********/
void main (void)
{
	delay(100);						//上电延时
	Init_ADXL345();                 //初始化ADXL345
	Init_UART();					//初始化串口通信
   	SpaceCreate(A);					//坐标系建立
	delay(200);
	OPTION=9;
	while( 1 )            			//循环
	{ 
		
		switch(OPTION)
		{
		case 1:
			STATUS_PRE=-1;
			STATUS_NOW=-1;
			STATUS_HISTORY[0]=0;
			STATUS_HISTORY[1]=0;
			STATUS_HISTORY[2]=0;
			OPTION=2;
		case 2:					  
			UpdateDatabase( DATABASE, A );
			AnalyzeDatabase( DATABASE, SET, ZArray);
			STATUS_HISTORY[0]=STATUS_HISTORY[1];
			STATUS_HISTORY[1]=STATUS_HISTORY[2];
			if ( isStill(SET) )
			{	
				STATUS_HISTORY[2]=StillStatus(SET);	
			}
			else
			{
				STATUS_HISTORY[2]=MovingStatus(ZArray);
			}
			if(STATUS_HISTORY[0]==STATUS_HISTORY[1]&&STATUS_HISTORY[2]==STATUS_HISTORY[1])
				STATUS_NOW=STATUS_HISTORY[2];
			else
				STATUS_NOW=STATUS_PRE;
			Send2PhoneMotion(STATUS_NOW, STATUS_PRE);
			STATUS_PRE=STATUS_NOW;
			break;
		case 3:
			temp=0;
			result=0;
			prestatus=0;
			OPTION=4;
		case 4:
			UpdateDatabase( DATABASE, A );
			AnalyzeDatabase( DATABASE, SET, ZArray);
			if ( isStill(SET) )
			{
				break;
			}
			result=Count( ZArray );
			if( prestatus==0 )
				prestatus=result/10;
			else if( prestatus!=result/10 )
			{
				temp=prestatus;
				prestatus=result/10;
				result=temp*10+result%10;
			}
			Send2PhoneSteps(result);
			break;
		case 9:
			break;
		}		
	}


}
void main ( void )
{
	ADI_ETHER_HANDLE   hEthernet;
	ADI_ETHER_RESULT   etherResult;
	ADI_ETHER_DEV_INIT EtherInitData[MAX_NETWORK_IF] = { { true, &memtable[0] }, { true, &memtable[1] }}; // data-cache,driver memory
	uint32_t reg_data;
	int i, nEtherDevUsed;
	char *ether_stack_block;

	ADI_GPIO_RESULT gpio_result;
	uint32_t gpioMaxCallbacks;
	int nRet;


	/**
	 * Initialize managed drivers and/or services that have been added to
	 * the project.
	 * @return zero on success
	 */
	adi_initComponents();
	
	/**
	 * The default startup code does not include any functionality to allow
	 * core 0 to enable core 1. A convenient way to enable core 1 is to use the
	 * 'adi_core_1_enable' function.
	 */
	adi_core_1_enable();
	
	/* Begin adding your custom code here */
	g_AuxiTMIsFirstUpdated = 1;
	
	/* init CGU first time */
	CGU_Init ( MULTIPLIER_SEL, CCLK_SEL, DDRCLK_SEL );				/* CCLK=16.384*iMultiplier /1 Mhz, 16.384*iMultiplier/iDDCLKSel Mhz DDR2 CLK */
	
#if defined(__DEBUG_FILE__)
    /* open the debug file */
    pDebugFile = fopen(__DEBUG_FILE_NAME__, "w");
    if (pDebugFile == 0)
    {
    	fclose(pDebugFile);
    	return;
    }
#elif defined(__DEBUG_UART__)
    Init_UART();
#endif

    Init_PTPAuxin();

	/* configures the switches */
#if BF609_EZ_BRD
	
	DEBUG_STATEMENT ( "Configuring switches for the ethernet operation \n\n" );
	ConfigSoftSwitches();
	
#endif
	
	/* open ethernet device */
	nEtherDevUsed = ( user_net_num_ifces > MAX_NETWORK_IF ) ? MAX_NETWORK_IF : user_net_num_ifces;

#if BF609_EZ_BRD
	nEtherDevUsed = 1;
#endif

	DEBUG_STATEMENT ( " init EMAC\n\n" );

	for ( i = 0; i < nEtherDevUsed; i++ )
	{
		etherResult = adi_ether_Open ( g_pDevEntry[i], &EtherInitData[i], g_pEthCallBack[i], &hEthernet );
		if ( etherResult != ADI_ETHER_RESULT_SUCCESS )
		{
			DEBUG_STATEMENT ( "adi_ether_Open: failed to open ethernet driver\n\n" );
			return ;
		}
		
		g_hDev[i] = hEthernet;
		
		/* get the mac address */
		memcpy ( ( ( ADI_EMAC_DEVICE * ) hEthernet )->MacAddress, user_net_config_info[i].hwaddr, 6 );

		/* allocate memory  */
		ether_stack_block = heap_malloc ( i+1, g_contEthHeapSize[i] );
		if ( ether_stack_block == NULL )
		{
			DEBUG_PRINT ( " heap_malloc: in heap %d, failed to allocate memory to the stack \n\n" , i+1);
			return ;
		}
		
		/* init buf mem */
		nRet = InitBuff ( g_contEthHeapSize[i],
				ether_stack_block, hEthernet,
				&user_net_config_info[i] );
		if( nRet<0 )
		{
			DEBUG_STATEMENT ( " InitBuff: failed to enable Init Buffs\n\n" );
			return ;
		}

		/* Enable the MAC */
		etherResult = adi_ether_EnableMAC ( hEthernet );
		if ( etherResult != ADI_ETHER_RESULT_SUCCESS )
		{
			DEBUG_STATEMENT ( " adi_ether_EnableMAC: failed to enable EMAC\n\n" );
			return ;
		}
	}
	
	//enable EMAC INT
	adi_int_EnableInt ( ( (ADI_EMAC_DEVICE *)g_hDev[0])->Interrupt, true);
	adi_int_EnableInt ( ( (ADI_EMAC_DEVICE *)g_hDev[1])->Interrupt, true);

	/* activate rx channel DMA */
	enable_rx ( g_hDev[0] );
	enable_rx ( g_hDev[1] );
	/* activate tx channel DMA */
	enable_tx ( g_hDev[0] );
	enable_tx ( g_hDev[1] );

	//enable emac0 tx,rx
	enable_emac_tx_rx (  g_hDev[0] );

	//enable emac1 tx,rx
	enable_emac_tx_rx (  g_hDev[1] );

	//enable
	Enable_Time_Stamp_Auxin_Interrupt();

	//
	HandleLoop();

	return ;

}//main
Beispiel #21
0
int main()
{
	GRID_RESET();
	rPIOD_PDR	= (1 << 12);
	rPIOD_BSR	= (1 << 12);
	rPIOE_PDR	= 0x80000000;
	rPIOE_BSR	= 0x80000000;
	
	
	rPIOC_PER	= 0x1F83;
	rPIOC_PDR	= 0xFFFFE07C;
	rPIOC_OER	= 0x0;
	rPIOC_ODR	= 0xFFFFFFFF;
	rPIOC_IFER	= 0x0;
	rPIOC_IFDR	= 0xFFFFFFFF;
	rPIOC_SODR	= 0x0;
	rPIOC_CODR	= 0x0;
	rPIOC_IER	= 0x0;
	rPIOC_IDR	= 0xFFFFFFFF;
	rPIOC_MDER	= 0x0;
	rPIOC_MDDR	= 0xFFFFFFFF;
	rPIOC_PUDR	= 0x0;
	rPIOC_PUER	= 0xFFFFFFFF;
	rPIOC_ASR	= 0xFFFFE07C;
	rPIOC_BSR	= 0x0;
	
	rSMC_SETUP(0) = (0 << 24) + (2 << 16) + (0 << 8) + (0 << 0);
	rSMC_PULSE(0) = (0 << 24) + (6 << 16) + (0 << 8) + (2 << 0);
	rSMC_CYCLE(0) = (0 << 23) + (8 << 16) + (0 << 7) + (6 << 0);
	rSMC_MODE(0) = (0 << 28) + (0 << 24) + (1 << 20) + (8 << 16) + (2 << 12) + (0 << 8) + (2 << 4) + (1 << 1) + (1 << 0);
	
	rSMC_SETUP(1) = (0 << 24) + (2 << 16) + (0 << 8) + (0 << 0);
	rSMC_PULSE(1) = (0 << 24) + (8 << 16) + (0 << 8) + (2 << 0);
	rSMC_CYCLE(1) = (0 << 23) + (10 << 16) + (0 << 7) + (6 << 0);
	rSMC_MODE(1) = (0 << 28) + (0 << 24) + (1 << 20) + (8 << 16) + (2 << 12) + (0 << 8) + (2 << 4) + (1 << 1) + (1 << 0);
	
	rSMC_SETUP(2) = (0 << 24) + (2 << 16) + (0 << 8) + (0 << 0);
	rSMC_PULSE(2) = (0 << 24) + (8 << 16) + (0 << 8) + (2 << 0);
	rSMC_CYCLE(2) = (0 << 23) + (10 << 16) + (0 << 7) + (6 << 0);
	rSMC_MODE(2) = (0 << 28) + (0 << 24) + (1 << 20) + (8 << 16) + (2 << 12) + (0 << 8) + (2 << 4) + (1 << 1) + (1 << 0);
	
	rSMC_SETUP(3) = (0 << 24) + (2 << 16) + (0 << 8) + (0 << 0);
	rSMC_PULSE(3) = (0 << 24) + (8 << 16) + (0 << 8) + (2 << 0);
	rSMC_CYCLE(3) = (0 << 23) + (10 << 16) + (0 << 7) + (6 << 0);
	rSMC_MODE(3) = (0 << 28) + (0 << 24) + (1 << 20) + (8 << 16) + (2 << 12) + (0 << 8) + (2 << 4) + (1 << 1) + (1 << 0);
	
	FPGA_CONF_P();
	GRID_RESET();
	
	BTNDIS_P();
	Init_LEDS();
	Init_TIMER();
	//Init_FPGA();
	Init_UART();
	//Init_TWI(100000);
	
	//mbootBanner();
	//Init_RTC();
	//Init_Media();
	//Init_SHA204();
	//Init_EMAC();
	SYS_UNRESET();
	GRID_UNRESET();
	//mboot();

	while(1)
	{
// 		*((volatile U32 *)(0x10000100)) = 0x22222222;
// 		*((volatile U32 *)(0x10000104)) = 0x33333333;
// 		*((volatile U32 *)(0x10000100)) = 0x44444444;
// 		*((volatile U32 *)(0x10000104)) = 0x55555555;
	}
}
Beispiel #22
0
// Main function
int main (void) 
{  
// Local variable definations
emxArray_uint8_T *xaxis;
emxArray_uint8_T *yaxis;
emxArray_uint8_T *norm_xaxis_filt;
emxArray_uint8_T *norm_yaxis_filt;

uint16_T count;
uint8_T xaxis2,yaxis2;

long j = 0;

int again = 1;

char letter;
char letterstr[10];
int i=0;
letterstr[i] = '\0';

// Variable Initialisation
	for(j=0;j<MAX_VALUE;j++)
	{
		xdata[j] = 0;
		ydata[j] = 0;
	}

	
// Function Initialisation
	PINSEL2 &= ~((1<<2)|(1<<3));
	GLCD_Initalize();				  //Initialize the LCD
	Init_UART();
	InitADC();

// Welcome message
	GLCD_ClearScreen();
	GLCD_GoTo(10,4);	
	GLCD_WriteString("Intelligent e-book");
//	for(j=0;j<999999;j++);
	delay_ms(2000);

// Calibration
	//Left bottom
	GLCD_ClearScreen();
	GLCD_GoTo(10,0);	
	GLCD_WriteString("Calibration");
	GLCD_GoTo(10,4);	
	GLCD_WriteString("Touch the point");
	GLCD_GoTo(0,7);	
	GLCD_WriteString("o");

	do
	{
	xaxis1 = Read_xaxis();
	yaxis1 = Read_yaxis();

	if(xaxis1<10)
		xaxis1 = 0;
	if(yaxis1<10)
		yaxis1 = 0;
	}while(xaxis1==0 && yaxis1==0);
	for(j=0;j<25;j++)
	capture();


	x1 = xaxis1;
	y1 = yaxis1;

	GLCD_GoTo(10,5);	
	GLCD_WriteString("Stored");
	delay_ms(1000);

	//Right top
	GLCD_ClearScreen();
	GLCD_GoTo(10,0);	
	GLCD_WriteString("Calibration");
	GLCD_GoTo(10,4);	
	GLCD_WriteString("Touch the point");
	GLCD_GoTo(120,0);	
	GLCD_WriteString("o");

	do
	{
	xaxis1 = Read_xaxis();
	yaxis1 = Read_yaxis();

	if(xaxis1<10)
		xaxis1 = 0;
	if(yaxis1<10)
		yaxis1 = 0;
	}while(xaxis1==0 && yaxis1==0);
	for(j=0;j<25;j++)
	capture();

	x2 = xaxis1;
	y2 = yaxis1;

	GLCD_GoTo(10,5);	
	GLCD_WriteString("Stored");
	delay_ms(1000);


while(again==1)
{
again = 0;

// Capturing xaxis and yaxis

GLCD_ClearScreen();
GLCD_GoTo(10,0);	
GLCD_WriteString("Intelligent e-book");
GLCD_GoTo(12,4);		
GLCD_WriteString("Waiting for input");
do
{
xaxis1 = Read_xaxis();
yaxis1 = Read_yaxis();

if(xaxis1<10)
	xaxis1 = 0;
if(yaxis1<10)
	yaxis1 = 0;

}while(xaxis1==0 && yaxis1==0);

xyelem = 0;
count = 0;
GLCD_ClearScreen();
GLCD_GoTo(0,0);		

// Eliminate first 25 samples
	for(j=0;j<25;j++)
	capture();

while(count!=250)
{
	capture();

	if(xaxis1!=0 && yaxis1!=0 && count==0)
	{
		
//	xaxis2 = (uint8_T)(((xaxis1-80)*255)/730);
//	yaxis2 = (uint8_T)(((yaxis1-100)*255)/650);
	xaxis2 = (uint8_T)(((xaxis1-x1)*255)/(x2-x1));
	yaxis2 = (uint8_T)(((yaxis1-y1)*255)/(y2-y1));

		count = 0;
	  	xdata[xyelem] = xaxis2;
		ydata[xyelem] = yaxis2;
		xyelem = xyelem + 1;
		GLCD_SetPixel(xaxis2/2,255-(yaxis2/4),1);

		if(xyelem>MAX_VALUE - 1)
		{
			GLCD_ClearScreen();
			GLCD_GoTo(10,0);	
			GLCD_WriteString("Intelligent e-book");
			GLCD_GoTo(10,4);		
			GLCD_WriteString("Overflow!!!");
			while(1);
		}
	}
	else if(xaxis1!=0 && yaxis1!=0)
	{
		xyelem = xyelem - 2;
		// Eliminate first 25 samples
		for(j=0;j<25;j++)
		capture();
		count = 0;
	}
	else
	{
	 	count = count + 1;
	}

//	delay(1000);
}
GLCD_ClearScreen();
GLCD_GoTo(10,0);	
GLCD_WriteString("Intelligent e-book");
GLCD_GoTo(0,1);	
GLCD_WriteString(letterstr);

//GLCD_GoTo(10,4);		
//GLCD_WriteString("Scanning ended");
//delay_ms(500);


// Transmitting data to PC
//	transmit();

// Remove noise
	remove_noise();

// Allocating space for pointers  
	xaxis = emxCreateWrapper_uint8_T(xdata,1,xyelem);	//xdata1
	yaxis = emxCreateWrapper_uint8_T(ydata,1,xyelem);	//ydata1
	emxInit_uint8_T(&norm_xaxis_filt, 2);
	emxInit_uint8_T(&norm_yaxis_filt, 2);

/*	GLCD_ClearScreen();
	GLCD_GoTo(10,0);	
	GLCD_WriteString("Intelligent e-book");
	GLCD_GoTo(0,2);		
	GLCD_WriteString("Step1");
	GLCD_GoTo(37,2);		
	GLCD_WriteString("In");
*/
//	for(j=0;j<999999;j++);

	step1(xaxis, yaxis, norm_xaxis_filt, norm_yaxis_filt);

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(54,2);	
//	GLCD_WriteString("Out");
//	for(j=0;j<999999;j++);

	emxDestroyArray_uint8_T(xaxis);
	emxDestroyArray_uint8_T(yaxis);
	
//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(0,3);	
//	GLCD_WriteString("Step2");
//	GLCD_GoTo(37,3);		
//	GLCD_WriteString("In");
//	for(j=0;j<999999;j++);

// char_bin is stored in column first fashion... each column vector are concatenated	
	step2(norm_xaxis_filt, norm_yaxis_filt, char_bin);

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(54,3);	
//	GLCD_WriteString("Out");
//	for(j=0;j<999999;j++);
	
	emxFree_uint8_T(&norm_xaxis_filt);
	emxFree_uint8_T(&norm_yaxis_filt);

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(0,4);	
//	GLCD_WriteString("Step3");
//	GLCD_GoTo(37,4);		
//	GLCD_WriteString("In");
//	for(j=0;j<999999;j++);

	for(j=0;j<10;j++)
	char_vec[j] = 1;
	
	step3(char_bin, char_vec);
	
//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(54,4);	
//	GLCD_WriteString("Out");
//	for(j=0;j<999999;j++);
  

	for(j=0;j<26;j++)
	char_vec1[j] = char_vec[j];
	
	// Feeding char_vec to trained neural network
	char_recog_nn(char_vec1,Y);

	letter = character();

	letterstr[i] = letter;
	letterstr[i+1] = '\0';

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(0,6);	
//	GLCD_WriteString("Letter is: ");
	GLCD_GoTo(0,1);	
	GLCD_WriteString(letterstr);
	GLCD_GoTo(0,7);	
	GLCD_WriteString("Continue");

	do
	{
	xaxis1 = Read_xaxis();
	yaxis1 = Read_yaxis();

	if(xaxis1<10)
		xaxis1 = 0;
	if(yaxis1<10)
		yaxis1 = 0;

	}while(xaxis1==0 && yaxis1==0);

again = 1;
i = i + 1;
/*
GLCD_ClearScreen();
GLCD_GoTo(10,0);	
GLCD_WriteString("Intelligent e-book");
GLCD_GoTo(20,4);		
GLCD_WriteString("Restarting.");
delay_ms(200);
GLCD_WriteString(".");
delay_ms(200);
GLCD_WriteString(".");
delay_ms(200);
GLCD_WriteString(".");
*/
delay_ms(400);
}

  while(1); 
}
int main(void){
volatile unsigned char a, b;
volatile unsigned int i, j[20], x; // volatile to prevent optimization

WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

P2DIR |= 0x02; // Set P1.0 to output direction

Init_UART();
Init_LCD();

j[0] = 0x5F;
j[1] = 0X06;
j[2] = 0X6B;
j[3] = 0X2F;
j[4] = 0X36;
j[5] = 0X3D;
j[6] = 0X7D;
j[7] = 0X07;
j[8] = 0X7F;
j[9] = 0X37;
j[10] = 0X77;
j[11] = 0X7C;
j[12] = 0X68;
j[13] = 0X6E;
j[14] = 0X79;
j[15] = 0X71;


//Run indefinitely
for (;;){

				//letter input 1
				a=INCHAR_UART();
				OUTA_UART(a);

				//Check if input is digit or character and print
				//onto the board's LCD screen
				if(isdigit(a)){
					a = a - 0x30;
					LCDSeg[1]=j[a];
				}
				else{
					a = a - 0x37;
					LCDSeg[1]= j[a];
				}
				//letter input 2
				b=INCHAR_UART();
				OUTA_UART(b);
				
				//Repeat procedure followed for input a
				if(isdigit(b)){
					b = b - 0x30;
					LCDSeg[0]=j[b];
				}
				else{
					b = b - 0x37;
					LCDSeg[0]= j[b];
				}

				Print New line
				OUTA_UART(0X0A);
				OUTA_UART(0X0D);

				
P2OUT ^= 0x02; // Toggle P1.0 using exclusive-OR
i = 10000; // SW Delay
do i--;
while (i != 0);
}
}
 int main(void){
volatile unsigned char d;
volatile unsigned int i, j[20], x[5], temp[3]; // volatile to prevent optimization
volatile unsigned int a, b, c, e;

WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

P2DIR |= 0x02; // Set P1.0 to output direction

Init_UART();
Init_LCD();

j[0] = 0x5F;
j[1] = 0X06;
j[2] = 0X6B;
j[3] = 0X2F;
j[4] = 0X36;
j[5] = 0X3D;
j[6] = 0X7D;
j[7] = 0X07;
j[8] = 0X7F;
j[9] = 0X37;
j[10] = 0X77;
j[11] = 0X7C;
j[12] = 0X68;
j[13] = 0X6E;
j[14] = 0X79;
j[15] = 0X71;



for (;;){

//letter input 1
				a=INCHAR_UART();
				OUTA_UART(a);

//Check if it's a digit or a character and transform to binary
				if((a>=0x30) && (a<=0x39)){
					a = a-0x30;
				}
				else{
					a = a-0x37;
				}

//letter input 2
				b=INCHAR_UART();
				OUTA_UART(b);


//Check if it's a digit or a character and transform to binary
				if((b>=0x30) && (b<=0x39)){
					b = b-0x30;
				}
				else{
					b = b-0x37;
				}


//Multiply a by 16 because of Hex, add together to obtain final number
				temp[1] = (a*16)+(b);
	
				d=INCHAR_UART();
				OUTA_UART(d);

//letter input 3
				a=INCHAR_UART();
				OUTA_UART(a);
//letter input 4
				b=INCHAR_UART();
				OUTA_UART(b);
				OUTA_UART(0x3D);


//Repeat procedure for the next two characters
				if((a>=0x30) && (a<=0x39)){
					a = a-0x30;
					}
				else{
					a = a-0x37;
				}

				if((b>=0x30) && (b<=0x39)){
					b = b-0x30;
				}
				else{
					b = b-0x37;
				}


//Multiply a by 16 because of Hex, add together to obtain final number
				temp[2] = (a*16)+(b);

//Multiply
				e = temp[1]*temp[2];

//The next few steps will be used to display our output
				x[4] = e/4096;
				temp[0]=e%4096;

				x[3]=temp[0]/256;
				temp[0]=temp[0]%256;

				x[2]=temp[0]/16;
				temp[0]=temp[0]%16;

				x[1]= temp[0];

//Print on LCD
				LCDSeg[3] = j[x[4]];
				LCDSeg[2] = j[x[3]];
				LCDSeg[1] = j[x[2]];
				LCDSeg[0] = j[x[1]];

//Convert our decimal characters back to ascii
				if(x[4]<=9)
					x[4]=x[4] + 0x30;
				else
					x[4]=x[4] + 0x37;

				if(x[3]<=9)
					x[3]=x[3] + 0x30;
				else
					x[3]=x[3] + 0x37;

				if(x[2]<=9)
					x[2]=x[2] + 0x30;
				else
					x[2]=x[2] + 0x37;

				if(x[1]<=9)
					x[1]=x[1] + 0x30;
				else
					x[1]=x[1] + 0x37;


//print the characters onto the Hyperterminal
				OUTA_UART(x[4]);
				OUTA_UART(x[3]);
				OUTA_UART(x[2]);
				OUTA_UART(x[1]);
//Print New line
				OUTA_UART(0X0A);
				OUTA_UART(0X0D);


}
}
Beispiel #25
0
void main(void)
{                            
   
    u16 i;                                      
    u8 shortcut = KEY_INVALID;  
    // RS485 Node    
    init_var();	//init data structure 
    // System Initialization
    Init_Port();
//    Init_Timers();
//    Init_Ex_Interrupt();
    Init_UART();  
    Enable_XMEM();
    Init_554();                
    InitLED();    
    Key_Init();    
    // Global enable interrupts
    WDTCR = 0x00; //disable dog watch
    #asm("sei")                 
    /*********************************************************************/
    // System hardware dection
    /*********************************************************************/
    // intialize LED. 
    nextwin = 0; 
    
    sleepms(20*ONEMS);
    LCD_Init();
    wnd_msgbox(&bootup);
    //init the DMM
    nav_command(NAV_INIT);              
    sleepms(200*ONEMS);                                
    navto1v();
    nav_command(NAV_SLOWMODE);
    sleepms(200*ONEMS);
    nav_command(NAV_AFLTON);
    sleepms(200*ONEMS);
                     
    sleepms(2*ONEMS); //wait until all the node is ready after power up        
    State_Init();	
    
    SET_BORE_MODE;
    
	 nextwin = PG_BOOTTYPE;
	 key = KEY_INVALID;

	 curr_ch = 1; //channel for display
	 curr_dispch = 1;
	 while(1)
	 {
 	 	if(nextwin != 0)
		{
			SwitchWindow(nextwin);
			(*curr_window)(MSG_INIT);
			nextwin = 0;
		}
		if(key != KEY_INVALID)
		{
			if((key == KEY_BTN1)||(key == KEY_BTN2)||(key == KEY_BTN3)||(key == KEY_BTN4))
			{                      
			        shortcut = key;          
                                //processing shortcut key
				if(curr_window == pgmain_handler)
				{
					LCD_Cls();
					wnd_msgbox(&modify);
				}
				if(shortcut == KEY_BTN1) //mode switch
				{
               			        SET_TOP1MA;
	                	        SET_TOPT1000;                				
					if(IS_BORE_MODE){
						SET_THERM_MODE;
					}else{
						SET_BORE_MODE;
					}
					dlg_cnt = 0;					
					onesec_cnt = 0;
					phase = 0;      //reset the state machine
				}
				if(shortcut == KEY_BTN2) //auto ktt or not
				{
					if(IS_BORE_MODE)
					{
                      			        SET_TOP1MA;
	                        	        SET_TOPT1000;                				
						if((IS_MODE_KTT)){
							CLR_MODE_KTT;
							SET_PKTT;
						}else{
							SET_MODE_KTT;
							SET_PKTT;
						}
        					dlg_cnt = 0;					
	        				onesec_cnt = 0;
		        			phase = 0;      //reset the state machine
					}
				}
				if(shortcut == KEY_BTN3) //thermal probe type
				{                            
					display_buttons(KEY_BTN3,1);
					if(IS_THERM_MODE)
					{                        
					        i = sysdata.tid[curr_dispch-1];
					        if(i != INVALID_PROBE)
					        {
                					if((tprbdata.type[i] >= PRBTYPE_K) &&\
	                				   (tprbdata.type[i] <= PRBTYPE_R))
		                			{
			                			if(tprbdata.type[i] == PRBTYPE_R)
				                			tprbdata.type[i] = PRBTYPE_K;
					                	else
						                	tprbdata.type[i] +=1;
        					        }                                                                                 
        					        if(rundata.reading[curr_dispch-1] > -9000)
                                                       		rundata.temperature[curr_dispch-1] = MValueToTValue(rundata.reading[curr_dispch-1], tprbdata.type[i]);
        					}
                                        }
					display_buttons(KEY_BTN3,0);
					
				}
				if(shortcut == KEY_BTN4) //remove zero
				{
					display_buttons(KEY_BTN4,1);
					if(IS_BORE_MODE){
					        sysdata.R0 = rundata.Rx;
					}else{             
					        //sysdata.V0 = nav_read();
					        nav_command(NAV_ZEROON);
					        sleepms(1000*ONEMS);
					}
					display_buttons(KEY_BTN4,0);
				}
				if(curr_window == pgmain_handler)       //redraw the running window
				{
					pgmain_handler(MSG_INIT);      
				}
			        shortcut = KEY_INVALID;
			        			        
			}else{
				(*curr_window)(key);
			}
			key = KEY_INVALID;
	  	}else{
			if(curr_window != pgmain_handler)
				continue;                               
			if(dlg_cnt > 1)
			{         
			        onesec_cnt++;
			        if(onesec_cnt == (ONESEC-10))
			        {       
        			        updatestate();
        			}
        			if(onesec_cnt == ONESEC)
        			        onesec_cnt = 0 ;
				dlg_cnt--;
				continue;
			}    
			updatestate();
			if((IS_THERM_MODE))			
			{
				if(therm_state() == 0)
				        continue;
			}else{
				if(bore_state() == 0)
				        continue;
			}     
			
                        //shift to next channel 
                       
                        while(true)
                        {
                                ch_to_search += 1;
        			if(ch_to_search >= MAX_CH_NUM)
        			{
	        			ch_to_search = 0;
	        			break;
	        		}           
	        		if(IS_THERM_MODE)
	        		{
	        		        i = sysdata.tid[ch_to_search];
	        		}else{
	        		        i = sysdata.rid[ch_to_search];
	        		}
	        		if(i == INVALID_PROBE)
	        		        continue;
	        		if(IS_THERM_MODE)
	        		{   
       					if((tprbdata.type[i] >= PRBTYPE_K) && (tprbdata.type[i] <= PRBTYPE_R))
       					        break;
	        		}else{
       		                        if((rprbdata.type[i] <= PRBTYPE_MAX) && (rprbdata.type[i] >= PRBTYPE_MIN))
       		        		        break;
	        		}
	                }
		}
	}	
}      
Beispiel #26
0
int main(void) {
    /* Ledstrips inits */
    /* W5100 defines */
    unsigned char sockstat;
    unsigned int rsize;
    char radiostat0[10], radiostat1[10];
    int postidx, getidx;
    /* Initial variable used */
    sockreg = 0;
    tempvalue = 0;
    ledmode = 0;

    Init_timer1();
    Init_timers();
    /*Init_shift();*/
    OSCTUN = 21;
    PLLFBD = 38; /* M=40 */
    CLKDIVbits.PLLPOST = 0; /* N1=2 */
    CLKDIVbits.PLLPRE = 0; /* N2=2 */
   /* Eraseleds();*/
    /* even ledstrips have to be mirrored */
   /* Mirror(patt); */

    /* LCD inits */
    Init_mcp();
    Init_LCD();
    Write_LCD(startup);

    /* W5100 inits */
    Init_pin_SPI();
    Init_SPI();
    W5100_Init(gtw_addr,mac_addr,sub_mask,ip_addr);
    T_SPI_CS;
    SPI_CS = 1;

    Init_UART();

    for (;;) {

        sockstat = SPI_Read(S0_SR);
        switch (sockstat) {
            case SOCK_CLOSED:
                if (socket(sockreg, MR_TCP, TCP_PORT) > 0) {
                    /* Listen to Socket 0 */
                    if (listen(sockreg) <= 0)
                        Delayms(1);
                }
                break;

            case SOCK_ESTABLISHED:
                /* Get the client request size */
                rsize = recv_size();
                if (rsize > 0) {
                    /* Now read the client Request */
                    if (recv(sockreg, buf, rsize) <= 0)
                        break;

                    Putstr(buf);
/*                    printf("%s",buf);*/
                    /* Check the Request Header */
                    getidx = strindex((char *) buf, "GET /");
                    postidx = strindex((char *) buf, "POST /");

                     if (getidx >= 0 || postidx >= 0) {

                        /* Now check the Radio Button for POST request */
                        if (postidx >= 0) {
                            if (strindex((char *) buf, "uBoard new color") > 0)
                                ledmode++;
                        }


            /* Create the HTTP Response	Header */
	    strncpy((char *)buf,("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"
                                "<body style=\"background-color:FFFFFF;\">\r\n"),96);

	    strcat((char *)buf,("[\n"
                                 "   {\n"
                                 "       \"id\": \"1\",\n"
                                 "       \"name\": \"uBoard webboard\",\n"
                                 "       \"ipaddr\": \"192.168.0.102\",\n"
                                 "       \"subnetmask\": \"255.255.255.0\",\n"
                                 "       \"gateway\": \"192.168.0.1\",\n"
                                 "       \"adjustSpeedOfPattern\": \"int\",\n"
                                 "       \"turnLedsOnOff\": \"boolean\"\n"
                                 "   }\n"
                                 "]\n"));




            /* Now Send the HTTP Response */
	    if (send(sockreg,buf,strlen((char *)buf)) <= 0) break;

            /* TODO: add status */
            LCD_Clear();
            LCD_PutByte(ledmode);
	    if (ledmode == 1) {
	      strncpy(radiostat0,"",0);
	      strncpy(radiostat1,("checked"),7);
	    } else {
	      strncpy(radiostat0,("checked"),7);
	      strncpy(radiostat1,"",0);
	    }

            /* Create the HTTP Radio Button Response */
	    strncpy((char *)buf,("<p><input type=\"radio\" name=\"radio\" value=\"0\" "),52);
	    strcat((char *)buf,radiostat0);
	    strcat((char *)buf,(">Turn off\r\n"));
	    strcat((char *)buf,("<br><input type=\"radio\" name=\"radio\" value=\"1\" "));
	    strcat((char *)buf,radiostat1);
	    strcat((char *)buf,(">Lounge mode\r\n"));
 	    strcat((char *)buf,("</strong><p>\r\n"));
	    strcat((char *)buf,("<input type=\"submit\">\r\n"));
	    strcat((char *)buf,("</form></span></body></html>\r\n"));            /* Now Send the HTTP Remaining Response */
	    if (send(sockreg,buf,strlen((char *)buf)) <= 0)
                break;


                    } /* Disconnect the socket */
                    disconnect(sockreg);
                } else
                    Delayms(1); /* Wait for request */
                break;

            case SOCK_FIN_WAIT:
            case SOCK_CLOSING:
            case SOCK_TIME_WAIT:
            case SOCK_CLOSE_WAIT:
            case SOCK_LAST_ACK:
                /* Force to close the socket */
                close(sockreg);

                break;
        }
    }
    return 0;
}
Beispiel #27
0
int main()
{
	U32 i;
	
	GRID_RESET();
	rPIOD_PDR	= (1 << 12);
	rPIOD_BSR	= (1 << 12);
	rPIOE_PDR	= 0x80000000;
	rPIOE_BSR	= 0x80000000;
	
	
	rPIOC_PER	= 0x1F83;
	rPIOC_PDR	= 0xFFFFE07C;
	rPIOC_OER	= 0x0;
	rPIOC_ODR	= 0xFFFFFFFF;
	rPIOC_IFER	= 0x0;
	rPIOC_IFDR	= 0xFFFFFFFF;
	rPIOC_SODR	= 0x0;
	rPIOC_CODR	= 0x0;
	rPIOC_IER	= 0x0;
	rPIOC_IDR	= 0xFFFFFFFF;
	rPIOC_MDER	= 0x0;
	rPIOC_MDDR	= 0xFFFFFFFF;
	rPIOC_PUDR	= 0x0;
	rPIOC_PUER	= 0xFFFFFFFF;
	rPIOC_ASR	= 0xFFFFE07C;
	rPIOC_BSR	= 0x0;
	
	rSMC_SETUP(0) = (0 << 24) + (2 << 16) + (0 << 8) + (0 << 0);
	rSMC_PULSE(0) = (0 << 24) + (6 << 16) + (0 << 8) + (2 << 0);
	rSMC_CYCLE(0) = (0 << 23) + (8 << 16) + (0 << 7) + (6 << 0);
	rSMC_MODE(0) = (0 << 28) + (0 << 24) + (1 << 20) + (8 << 16) + (2 << 12) + (0 << 8) + (2 << 4) + (1 << 1) + (1 << 0);
	
	rSMC_SETUP(1) = (0 << 24) + (2 << 16) + (0 << 8) + (0 << 0);
	rSMC_PULSE(1) = (0 << 24) + (8 << 16) + (0 << 8) + (2 << 0);
	rSMC_CYCLE(1) = (0 << 23) + (10 << 16) + (0 << 7) + (6 << 0);
	rSMC_MODE(1) = (0 << 28) + (0 << 24) + (1 << 20) + (8 << 16) + (2 << 12) + (0 << 8) + (2 << 4) + (1 << 1) + (1 << 0);
	
	rSMC_SETUP(2) = (0 << 24) + (2 << 16) + (0 << 8) + (0 << 0);
	rSMC_PULSE(2) = (0 << 24) + (8 << 16) + (0 << 8) + (2 << 0);
	rSMC_CYCLE(2) = (0 << 23) + (10 << 16) + (0 << 7) + (6 << 0);
	rSMC_MODE(2) = (0 << 28) + (0 << 24) + (1 << 20) + (8 << 16) + (2 << 12) + (0 << 8) + (2 << 4) + (1 << 1) + (1 << 0);
	
	rSMC_SETUP(3) = (0 << 24) + (2 << 16) + (0 << 8) + (0 << 0);
	rSMC_PULSE(3) = (0 << 24) + (8 << 16) + (0 << 8) + (2 << 0);
	rSMC_CYCLE(3) = (0 << 23) + (10 << 16) + (0 << 7) + (6 << 0);
	rSMC_MODE(3) = (0 << 28) + (0 << 24) + (1 << 20) + (8 << 16) + (2 << 12) + (0 << 8) + (2 << 4) + (1 << 1) + (1 << 0);
	
	FPGA_CONF_P();
	GRID_RESET();
	
	BTNDIS_P();
	Init_LEDS();
	Init_TIMER();
	//Init_FPGA();
	Init_UART();
	//Init_TWI(100000);
	
	//mbootBanner();
	//Init_RTC();
	//Init_Media();
	//Init_SHA204();
	//Init_EMAC();
	SYS_UNRESET();
	GRID_UNRESET();
	//mboot();

U32 j, k, a;

	while(1)
	{
		if((gSYS_ID == 0x1)&&(gSYS_ID_FLAG == 0xEA68)){
			grid_func_led_set(0, 0, 0x60, 0x15);
			grid_func_led_set(1, 0, 0x60, 0x15);
			grid_func_led_set(2, 0x60, 0, 0x15);
			grid_func_led_set(3, 0x60, 0, 0x15);
			
			grid_shield_a_lo_en();
			grid_shield_a_hi_en();
			grid_shield_b_lo_en();
			grid_shield_b_hi_en();
			grid_shield_a_pwr_en();
			grid_shield_b_pwr_en();

			for(i=0; i<26; i++) {
				GRID_PWM(i)->PWM_RESET = 0;
				GRID_PWM(i)->PWM_GATE = 0x0000FFFF;
			}
			
			for(i=0; i<26; i++){
				for(j=0; j<=0x8000; j = j+0x200){
					if(i >= 2) GRID_PWM((U8)(i-2))->PWM_DTYC = j/128;
					if(i >= 1) GRID_PWM((U8)(i-1))->PWM_DTYC = j/8;
					GRID_PWM(i)->PWM_DTYC = j;
					if(i <= 25) GRID_PWM((U8)(i+1))->PWM_DTYC = j/8;
					if(i <= 24) GRID_PWM((U8)(i+2))->PWM_DTYC = j/128;				
					Delay_ms(20);
				}
				
				Delay_ms(50);
				
				for(j=0; j<=0x8000; j = j+0x200){
					if(i >= 2) GRID_PWM((U8)(i-2))->PWM_DTYC = (0x8000 - j)/128;
					if(i >= 1) GRID_PWM((U8)(i-1))->PWM_DTYC = (0x8000 - j)/8;
					GRID_PWM(i)->PWM_DTYC = 0x8000 - j;
					if(i <= 25) GRID_PWM((U8)(i+1))->PWM_DTYC = (0x8000 - j)/8;
					if(i <= 24) GRID_PWM((U8)(i+2))->PWM_DTYC = (0x8000 - j)/128;
					Delay_ms(10);
				}
				
				Delay_ms(50);
			}
			
 			GRID_PIO26_SLOT_A->PIO_DOE = (0xFFFFFFFF);
 			GRID_PIO26_SLOT_B->PIO_DOE = (0xFFFFFFFF);

 			for(i=0; i<4; i++)
 			{
 				GRID_PIO26_SLOT_A->PIO_DOUT[i] = (0x0);
 				Delay_ms(200);
 				GRID_PIO26_SLOT_A->PIO_DOUT[i] = (0xFF);
 			}

 			for(i=0; i<26; i++)
 			{
 				GRID_PIO26_SLOT_A->PIO_IO[i] = 0;
 				Delay_ms(50);
 				GRID_PIO26_SLOT_A->PIO_IO[i] = 1;
 			}
		}
	}
}