Esempio n. 1
0
void main(void)
	{
	InitVoice();

	InitUART(BAUD1200);

	#ifdef F2
	InitUART(BAUD9600);
	#endif

	// �����жϳ�ʼ��
	press_open_button = 1;
	press_close_button = 1;
	
	#ifdef WX
	KBLS1 |= 0x03;
	KBLS0 |= 0x03;
	KBIF &= 0xfc;
	KBIE |= 0x03;
	EKB = 1;
	#endif

	EA = 1;

//	Moto_EN = 1;		//��ʼ�����ر����
	voice_EN = 0;		  	//����ʱ�������Źر�
	P10 = 1;
	
//	ADC_check_result = 0x3ff;
	
	stolen_alarm_count = 0;			//�屨��������
	stolen_alarm_flag = 0;			//�屨����־

//	transmit_wire = 0;
	transmiter_EN = 0;		// turn off the transmitter
	receiver_EN = 0;			// turn on the receiver
	transceiver_power_enable = 0;         // �ϵ�ʱ����ģ���Դ�ر�


	while(1)
		{
		#ifdef Z2
		if(idle_EN == 1)
			{
			idle_EN = 0;
			PCON |= 0x02;			
			}
		#endif
			
		
		sEOS_Go_To_Sleep();			
		}
	}
Esempio n. 2
0
void init_system (void)
{
    init_clock();

    OVERFLOW_CODEUR[CODEUR_D] = PAS_D_OVERFLOW_CODEUR;
    OVERFLOW_CODEUR[CODEUR_G] = PAS_D_OVERFLOW_CODEUR;

    position[CODEUR_D].ancien = 0;
    position[CODEUR_G].ancien = 0;
    position[CODEUR_D].nouvelle = 0;
    position[CODEUR_G].nouvelle = 0;
    
    config_timer_10ms();
    config_timer_5ms();
    config_timer_90s();

    ConfigMapping ();
    ConfigPorts ();
    ConfigQEI ();
    ConfigInterrupt ();
    ConfigPWM();
    //ConfigADC();

    InitUART(UART_XBEE, 115200);
    InitUART(UART_AX12, 500000);

    // Evitement
    DETECTION = OFF;
    EVITEMENT_ADV_AVANT = OFF;
    EVITEMENT_ADV_ARRIERE = OFF;
    STRATEGIE_EVITEMENT = STOP;
    FLAG_EVITEMENT_STRATEGIQUE = NE_RIEN_FAIRE;

    // AUTOMS
    FLAG_ACTION = NE_RIEN_FAIRE;
    ETAT_AUTOM = NE_RIEN_FAIRE;
    COULEUR = VIOLET;
    COMPTEUR_MARCHE = 0;

    COMPTEUR_TEMPS_MATCH = 0;

    TIMER_5ms = ACTIVE;

#ifdef PETIT_ROBOT
    TRISCbits.TRISC2 = 0;
#endif
#ifdef GROS_ROBOT
    //TRISAbits.TRISA3 = 0;
#endif
    
    init_flag();
}
Esempio n. 3
0
int main(void) {
    uint16_t tempSensor, battery;
    uint8_t capPushA, capPushB;
    uint8_t it=1;

    InitWDT();
    InitCLOCK();
    InitUART();
    InitLED();
    InitADC();
    InitBuzzer();
    InitCapPush();
    
    EnableInterrupts();
    while (1) {
        it--;
        if(it == 0) {
            it = 4;
            capPushA = senseCapPushA(); 
            capPushB = senseCapPushB(); 
            tempSensor = ReadTemp();
            battery = ReadBattery(); 
            MainLoop(capPushA, capPushB, tempSensor, battery);
        }
        SetupWDTToWakeUpCPU(2); // Wake up in 16 mS
        Sleep();
    }
    return 0;
}
Esempio n. 4
0
/*
 * main.c
 */
int main(void) {
	WDTCTL = WDTPW | WDTHOLD;		// Stop watchdog timer

	// Set up master clk
	DCOCTL |= DCO2 | DCO1 | DCO0;
	BCSCTL1 |= RSEL3 | RSEL2 | RSEL1 | RSEL0;

	// Initilize communications
	InitUART();
	InitSPI();

	// Enable interrupts
	__enable_interrupt();
	IE2 = UCA0TXIE | UCA0RXIE | UCB0TXIE | UCB0RXIE;

	//while(!(IFG2 & UCA0RXIFG));

	//uint8_t echo = UCA0RXBUF;

	while(1) {
		//UARTTransmit(echo);
		//while(!(IFG2 & UCA0RXIFG));
		//echo = UCA0RXBUF;
	}

	return 0;
}
int main (void)
{
	uint16_t heading;
	int16_t pitch, roll;
	uint16_t headingIntegerPart, headingFractionPart;
	int16_t pitchIntegerPart, pitchFractionPart;
	int16_t rollIntegerPart, rollFractionPart;

	// initialize the hardware stuff we use
	InitTimer ();
	InitUART ();
	i2c_init ();

	fdevopen (UART0_PutCharStdio, UART0_GetCharStdio);

	// set the LED port for output
	LED_DDR |= LED_MASK;

	printf ("\nHoneywell HMC6343 I2C Compass Test\n\n");

	// Flash the LED for 1/2 a second...
	turnOnLED ();
	ms_spin (500);
	turnOffLED ();

	while (1)	// outer loop is once every 250 ms (more or less)
	{
		// send the HEADING command to the compass
		i2c_start_wait (COMPASS_ADDRESS_WRITE);
		i2c_write (COMPASS_HEADING_COMMAND);

		// now read the response
		i2c_rep_start (COMPASS_ADDRESS_READ);
		heading = (i2c_readAck () * 256) + i2c_readAck ();
		pitch = (i2c_readAck () * 256) + i2c_readAck ();
		roll = (i2c_readAck () * 256) + i2c_readNak ();
		i2c_stop ();

		headingIntegerPart = heading / 10;
		headingFractionPart = heading - (headingIntegerPart * 10);
		pitchIntegerPart = pitch / 10;
		pitchFractionPart = pitch - (pitchIntegerPart * 10);
		if (pitchFractionPart < 0)
			pitchFractionPart *= -1;
		rollIntegerPart = roll / 10;
		rollFractionPart = roll - (rollIntegerPart * 10);
		if (rollFractionPart < 0)
			rollFractionPart *= -1;

		printf ("Heading: %3d.%1d   Pitch: %3d.%1d   Roll: %3d.%1d\n", headingIntegerPart, headingFractionPart, pitchIntegerPart, pitchFractionPart, rollIntegerPart, rollFractionPart);

		turnOnLED ();
		ms_spin (100);
		turnOffLED ();
		ms_spin (150);
	}

	// we'll never get here...
	return 0;
}
Esempio n. 6
0
/*------------------------------------------------
                    主函数
------------------------------------------------*/
void main (void)
{
	unsigned char temp = 0,UserValidLen = 9;
	InitUART();
	HekrInit(SendByte);
	HekrValidDataUpload(UserValidLen);
  	HekrModuleControl(HekrConfig);
	while(1)
	{
		if(Recv_STA)
		{
			temp = HekrRecvDataHandle(Recv_Buffer);
			if(ValidDataUpdate == temp)
			{
				//接收的数据保存在 valid_data 数组里
				//User Code
				SendByte(valid_data[0]);
			}
			if(HekrModuleStateUpdate == temp)
			{
				//接收的数据保存在 ModuleStatus 指针里
				//User Code.
				SendByte(ModuleStatus->CMD);
			}
			Recv_STA = 0;		
		}
	}
}
Esempio n. 7
0
void main()
	{
	InitVoice();
	
	// lock the external motor, prohibit motor moving when power up.
	InitElecmotor();	
	
	InitUART(BAUD9600);

//	#ifdef WX
//	InitUART(BAUD1200);
//	#endif
	
	InitSensor();
	
	InitTransceiver();
	
  
	Externalmotor = Close;

	Flash_Page_Erase(0x3000);

	Flash_Write_Data(0x3000, 0x00);		
	Flash_Write_Data(0x3001, 0x25);		
	Flash_Write_Data(0x3002, 0x12);		
	Flash_Write_Data(0x3003, 0xf7);		
	Flash_Write_Data(0x3004, 0x85);
	transmiter_EN = 1;
	
	while(1)
		{		
		}
	}
void HardwareInit()
{
  IntMasterDisable();
  
  // Set the system clock to run at 50MHz from the PLL. // PLL=400MHz
  // sysc2000000lk = 400MHz/2/4 = 50MHz
  //SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

  ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

  // Set the system clock to run at 20MHz from the PLL. // PLL=100MHz
  // sysc2000000lk = 100MHz/2/4 = 20MHz
  //SysCtlClockSet(SYSCTL_SYSDIV_10| SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
  ulSysClock = ROM_SysCtlClockGet();
  
   
  if (InitUART(UART0_BASE,SysCtlClockGet(),19200,
      	(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)) == -1)
      	  while (1);    // hang

  if (InitUART(UART1_BASE,SysCtlClockGet(),9600,
      	(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)) == -1)
      	  while (1);    // hang
      
  SysTickInit(1000); // 1msec counter
  TimerInit(1);    	 // 100ms counter
  
  BBLedInit();  
  DEBUG_LED1(1);
  DEBUG_LED1(0);  
  DEBUG_LED2(1);	 
  DEBUG_LED2(0);	 

  MasterI2C0Init(SysCtlClockGet() >= 40000000L);  // Need 40MHz for 400K
  A3906Init(); 
  RMBD01Init();
  Encoder_Init(QEI0_BASE);   // J6 PITCH Encoder 
  Encoder_Init(QEI1_BASE);   // J8 ROLL Encoder
  EncoderLinesSet(QEI0_BASE,64);
  EncoderLinesSet(QEI1_BASE,64);
  //HBridgeInit();

  //GPIOPinInit('E',4,false,false); /*TP5 */
  //GPIOPinInit('E',5,false,false); /*TP6 */

  IntMasterEnable();
}
Esempio n. 9
0
void main(void){
  InitUART();
  ES=0;
  sendString("123456789\n");
  ES=1;//打开串口中断
  // while(1){
  //
  // }
}
Esempio n. 10
0
static void ReadLoggingFlag ( void )
{
	loggingFlag = eeprom_read_byte((uint16_t*)(CALIBRATION_EEPROM_BASE + LOGGING_FLAG_LOCATION));
	if (loggingFlag) {
		InitUART ();
		fdevopen (UART1_PutCharStdio, UART1_GetCharStdio);
		turnOnAsyncCapture();
	}
}
Esempio n. 11
0
/*------------------------------------------------
                    主函数
------------------------------------------------*/
void main (void)
{
	InitUART();
	SendStr("51单片机开发板串口测试程序\r\n\t南京爱思电子\r\n");
	ES = 1;                 
	while (1)                       
    {
    }
}
Esempio n. 12
0
/****************************************************************************
 Function
     InitGridlinq

 Parameters
     uint8_t : the priorty of this service

 Returns
     bool, false if error in initialization, true otherwise

 Description
     Initializes the UART and Pins necessary for communication
****************************************************************************/
bool InitGridlinq ( uint8_t Priority ) {
    MyPriority = Priority;
    CurrentState = Detached;
	
    InitUART();
    // post the initial transition event
    ES_Event ThisEvent = {ES_INIT,0};
    return ES_PostToService(MyPriority, ThisEvent);
}
Esempio n. 13
0
//Initialize system
void Init()
{
	unsigned int		i;

	IFG1 &= ~OFIFG;

	// Stop watchdog timer to prevent time out reset
    WDTCTL = WDTPW + WDTHOLD;

	//Adjust DCO frequency
//    //DCOCTL	= DCO0 + DOC1 +DOC2;
//	DCOCTL	= 0x80;
//	BCSCTL1	= XT2OFF + RSEL0 + RSEL1 + RSEL2;
//	BCSCTL2	= 0;

	//调整DCO的频率
	DCOCTL = 0xE0;

	//切换MCLK到外部高速晶振(需要检测是否起振)
	//BCSCTL1 &= ~XT2OFF;		//启动高速晶振
	BCSCTL1 = RSEL0 + RSEL1 + RSEL2;

	do
	{
		//清除振荡器失效标志位,再延迟检查
		IFG1 &= ~OFIFG;
		for (i = 0; i < 1000; i++)
		{
			__no_operation();
		}
	} while (IFG1 & OFIFG);

	//使用XT2, SMCLK = MCLK = 8MHz
	BCSCTL2 = SELM1 + SELS;

	//允许外部振荡器失效后,重启系统
	IE1 |= OFIE;


	InitPort();

	InitUART();

	InitADC();

	InitSPI();

	InitRF();

	InitSensors();

	InitTimer();


	ShutdownModule();
}
Esempio n. 14
0
/* Main - a simple test program*/
void main( void )
{
	InitUART( 11 );   /* Set the baudrate to 19,200 bps using a 3.6864MHz crystal */

	_SEI();           /* Enable interrupts => enable UART interrupts */

	for( ; ; )        /* Forever */
	{
		TransmitByte( ReceiveByte() ); /* Echo the received character */
	}
}
Esempio n. 15
0
//-----------------------------------------------------------------------------
// Main function
//-----------------------------------------------------------------------------
int main(void) {

	WDT_INIT();
	InitMCU();
	initRotary();
	InitUART();
	timer_init();
	rotary__GetValue();
	nRF24L01_Initial();

	// initialize dmx driver
	MDP_SendDimmingReqToMDP(0xff, 0xFF);

	//DMX512Send();
	PORTC = 0x00;

	TCCR1A = 0x00;
	TCCR1B = 0x06;
	TCNT1H = 0xFF;
	TCNT1L = 0xFF;

	TIMSK |= 0x04;

	ZRMSendSetPreconfig(0x15);
	MSLEEP(100);
	ZRMSendReset();
	MSLEEP(1000);

	timer_set(ON_WTD_TIMER_ID, 500);
	timer_set(ON_TEST_TIMER_ID, 3000);

	timer_set(ON_ZIGBEE_PING_TIMER_ID, 3000);
	timer_set(ON_ONTIME_TIMER_ID, 100);
	timer_set(NCP_TIMER_ID, 2000);

	tmp_zrmp.zrm_State = ZRM_INIT;

	xcps_init_zigbee(USART0_Receive, USART0_Transmit);
	xcps_init_rs485(USART1_Receive, USART1_Transmit);
//	FILE mystdout =
	TX_Mode(0);
//			FDEV_SETUP_STREAM((void *)USART0_Transmit, NULL, _FDEV_SETUP_WRITE);
//	stdout = &mystdout;
//
//	DEBUG("\n\r=========START PROGRAM ===========\n\r");
	while (1) {
		ledTask();
		ZigbeeUsartTask();
		NCP_Task();
	}

	return 0;
}
Esempio n. 16
0
void  InitBoardDev(void)
{

    GPIO_Config();

    //LED
    GPIO_ResetBits(GPIOD, GPIO_Pin_3);

    InitUARTQBuff();
    USART_DeInit(USART1);
    InitUART(USART1,115200);
    //printf("USART1 test\n");

    USART_DeInit(USART2);
    InitUART(USART2,115200);
    //printf("program is running\n");

    ///InitTimer2();

    ///Delay(1000);

    ///Delay(1000);
    InitTimer5();

    //InitRTC();
    //RTC_AlarmConfig();

    ///InitSimuI2C();

    //InitTimer3();
    //InitTimer4();
    //InitTimer7();

    //CheckID(); //检查ID,检查返回值,并作相应处理



}
Esempio n. 17
0
void main(void)
	{
	noVoice();

	InitUART();
	InitT0(50);
    TR0 = 1;
	TI = 0;
	RI = 0;
	ES = 1;
	ET0 = 1;
	PS = 1;

	// �����жϳ�ʼ��
	press_open_button = 1;
	press_close_button = 1;
	
	KBLS1 |= 0x03;
	KBLS0 |= 0x03;
	KBIF &= 0xfc;
	KBIE |= 0x03;
	EA = 1;

	Moto_EN = 1;		//��ʼ�����ر����
	transmit_wire = 1;
	voice_EN = 0;		  	//����ʱ�������Źر�
	
	ADC_check_result = GetADCResult(6);		//�ϵ�ʱ����ص������һ��
	
	stolen_alarm_count = 0;			//�屨��������
	stolen_alarm_flag = 0;			//�屨����־

	transmiter_EN = 0;		// turn off the transmitter
	receiver_EN = 0;		// turn on the receiver

	transceiver_power_enable = 1;         // �ϵ�ʱ����ģ���Դ�ر�
	
	while(1)
		{				
		if(idle_EN == 1)
			{
			EKB = 1;
			idle_EN = 0;
//			PCON |= 0x02;			
			}
		
//		sEOS_Go_To_Sleep();			
		}  
	}
Esempio n. 18
0
/*! \brief Init of peripheral devices.
 *
 *  Setup IO, uart, stepper, timer and interrupt.
 */
void Init(void)
{
  // Init of IO pins
  sm_driver_Init_IO();
  // Init of uart
  InitUART();

  // Set stepper motor driver output
  sm_driver_StepOutput(0);

  // Init of Timer/Counter1
  speed_cntr_Init_Timer1();

  __enable_interrupt();
}
Esempio n. 19
0
int main(void)
{
    int     i;

    InitTimer();
    InitUART();

    LED_DDR |= LED_MASK;

    // The first handle opened for read goes to stdin, and the first handle
    // opened for write goes to stdout.

    fdevopen( UART0_PutCharStdio, UART0_GetCharStdio );

    printf( "*****\n" );
    printf( "***** Uart Test program\n" );
    printf( "*****\n" );

    while( 1 )
    {
        LED_PORT ^= LED_MASK;

        printf( "." );

        // Tick rate is 100/sec so waiting for 100 waits for 1 sec

        for ( i = 0; i < 100; i++ ) 
        {
            WaitForTimer0Rollover();

            if ( UART0_IsCharAvailable() )
            {
                char    ch = getchar();

                printf( "Read: '%c'\n", ch );

                if ( ch == ' ' )
                {
                    printf( "*** Press a key to continue\n" );
                    ch = getchar();
                    printf( "*** Continuing...\n" );
                }
            }
        }
    }

    return 0;
}
Esempio n. 20
0
int main()
{
	char tegn;
	char TestStreng[40] = "This string is stored in SRAM memory\r\n";

	// Initialize USART
	// Important : Also other Baud Rates and Data Bits should be tested
	// Corresponding changes has to be made in the terminal program used
	// for the test
	InitUART(9600, 8);

	while (1)
	{
		// Testing SendChar
		SendChar('A');
		SendChar('B');
		SendChar('C');
		SendChar('\r');
		SendChar('\n');

		// Testing ReadChar() : Read and echo
		tegn = ReadChar();
		SendChar(tegn);
		SendChar('\r');
		SendChar('\n');

		// Testing CharReady()
		while ( !CharReady() )
	{}
		SendChar( ReadChar() );
		SendChar('\r');
		SendChar('\n');
		
		// Sending string stored in Flash (constant string)
		SendString("This string is stored as a constant in flash memory\r\n");
		
		// Sending string stored in SRAM (modify-able string)
		SendString(TestStreng);
		
		// Testing SendInteger()
		SendInteger(12345);
		SendChar('\r');
		SendChar('\n');
		SendInteger(-1000);
		SendChar('\r');
		SendChar('\n');
	}
}
Esempio n. 21
0
void main(void)
//-----------------------------------------------------------------------------------------------------
//  Purpose:	The MCU will come here after reset. 
//  
//
//  Rev:    1.5a     TEMPLATE RELEASE
//  
//  Notes:          None    
//-----------------------------------------------------------------------------------------------------
{
	
	//Initialization function calls 
	init_ports();
	motors_init();
	system_clock_init();
	InitDisplay("FHBTEST    "); //Start-up splash changed to unity ID
	InitUART();
	ADInit();	
	ENABLE_SWITCHES;	
	/* LED initialization - macro defined in qsk_bsp.h */
 	ENABLE_LEDS	


	//Polling for switch presses 
	while(TRUE) 
	{
		if(S1 == PRESSED)
		{
			BNSPrintf(LCD,"\tTEST          \n        ");
			project2ADemo(); 		
		}
		else if (S2 == PRESSED)
		{
			BNSPrintf(LCD,"\tOff            \n        ");
		}
		else if (S3 == PRESSED)
		{
			BNSPrintf(LCD,"\tFigure 8              \n        ");
			DoFigureEight();
		}
		else
		{
       		BNSPrintf(LCD,"\tTeam 2                 \n        ");
        }
		
	}
}
Esempio n. 22
0
void main( void )
{
  WDTCTL     = WDTPW + WDTHOLD                                     ; // 关看门狗
  BoardConfig(0xf0);
  Init_Port();
  InitUART();
  _EINT()                                            ;
  PcdReset();//复位RC522
  PcdAntennaOn();//开启天线发射 
  DisplayConfigMenu();
  while(1)
  {
        Send1Char('>');
        Send1Char('\n');
        i=Get1Char();
        HandleConfigMenu(i);
  }
}
Esempio n. 23
0
void main() {
    // Set OSC to 64 MHz
    OSCCON = 0xF4;
    OSCCON2 = 0x80;
    OSCTUNE = 0xFF;

    // Setup output pins
    ANSELC = 0;
    TRISB = 0x00;
    TRISD = 0x00;
    LATB = 0x00;


    SetDefaults();
    InitDriverI2C();
    InitUART();
    Alive();

    Delay_us(1000);

    // Reset the Drivers
    TLC59116_ResetAll();
    TLC59116_Setup();

    // Run Idle Pattern before allowing input
    IdlePattern();

    // Enable all interrupts
    INTCON.GIE = 1;
    INTCON.PEIE = 1;


    while(1) {
        Refresh();
        auto_idle_counter++;

        if((auto_idle_counter > auto_idle_timeout) && auto_idle_enable && auto_idle_flag) {
            IdlePattern();
            auto_idle_counter = 0;
            auto_idle_flag = 0;
        }
    }
}
Esempio n. 24
0
void main()
{

    int adc_result;
    InitUART(9600, 8);      // UART'en initieres.
  
    ///// PWM ////////////////
    DDRD.5 = 1;             // Port D.5(OCR1A) initieres til en udgang.
    TCCR1A = 0b10000011;    // non-inverting
    TCCR1B = 0b00000010;    // Prescale sættes til 8. CS12, CS11 og CS10 sættes til hhv. 010
                              // Register TCCR1A og B initieres. "Phase Correct PWM mode", 10 bit
                              //
    OCR1A = 0;              // PWM signalet sætter som udgangspunkt til nul. Dioden lyser ved maksimal styrke.
    //////////////////////////
  
    ////// ADC ///////////////
    ADMUX = 0b01000000;     // Multiplex'eren vælger ADC0, ADLAR = 0, intern 5 volts referance.
    ADCSRA = 0b11000101;    // ADCSRA registeret tændes, div factor på 32(frekvensen ligger mellem 50 og 200 Hz)
                            // Konverteringen sættes igang.
    //////////////////////////
  
    while(1)
    {
       
             //
        if(ReadChar() == 'R')
        {  
            ADCSRA.6 = 1;   // Konverteringen startes igen   
            ////// ADC /////////////////
            while (ADCSRA.6)          // Den springer først over "while", når konverteringen er færdig.
            {}  
                     
            adc_result = ADCW;        // Resultatet fra ADC gemmes i en variabel.
            SendInteger(adc_result);  // Resultatet fra AD konverteringen sendes i terminalen.
            SendChar('\n');    
       
          
        }
    
    }
    
}
Esempio n. 25
0
 int main( void )
  {
   InitVFD();
   InitISD();
   InitI2C();
   InitADC();
   InitRTC();
   InitDS75();
   InitKeys();
   InitUART();
   InitRFM();
   InitAlarm();

   sei();
   wdt_enable(WDT_DEFAULT);

   UI();   

   return 0;
 }
Esempio n. 26
0
int main(void) {

	//Initialize the device
	InitDevice();

	//Initialize the UART
	InitUART();

	//Enable global interrupts
	eint();

	InitPWM();

	SetFanLevel(FAN_STATE_1);

	while(1)
	{
		//Loop forever, interrupts take care of the rest
	}

}
Esempio n. 27
0
int main(void)
{
	InitUART();
	printf("\n\n**************************************************");
	printf("\nAVR-Ethernet");					//DEBUG
	printf("\n**************************************************\n");
	printf("\nInitalizing SPI...");				//DEBUG
	SpiMasterInit();
	printf("initialization done.");				//DEBUG
	

	
    while(1)
    {
		int user_input = 0xFFFF;
			
	    printf("\n\nSelect an option:");
	    printf("\n\t0: Option zero");
	    printf("\n\t1: Option one\n");
		 
		scanf("%d", &user_input);
		
		switch (user_input)
		{
			case 0 :
			printf("\nYou entered 0");
			break;
			case 1 :
			printf("\nYou entered 1");
			break;
			default	:
			printf("\nERROR, invalid entry");
			break;
		}
		
		while(1)
		{
		}
    }
}
Esempio n. 28
0
int main(void)
{
	InitUART(9600, 8);
	
	SendString("Hej UART \r\n");
	
	BMP180_Init(102600);
	
	while(1)
	{	
		SendString("Device id: ");
		SendInteger((int)BMP180_GetDeviceId());
		SendString("\r\n \r\n");
		
		SendString("Temperature: ");
		SendInteger(BMP180_GetTemperature());
		
		SendString("\r\n-----------------\r\n");
		
		_delay_ms(1000);
    }
	
	return 1;
}
Esempio n. 29
0
int main( void )
{
    uint8_t delay;
    uint8_t counter;
    uint8_t doStatus = 1;

    InitTimer();
    InitUART();

    SetDirectionOut( LED );

    SetDirectionOut( MOSI );
    SetDirectionIn(  MISO );
    SetDirectionOut( SCK );
    SetDirectionOut( SS );
    SetDirectionIn(  INT );
    SetDirectionOut( TRIGGER );

    TRIGGER_PORT &= ~TRIGGER_MASK;

    SPI_MasterInit();

    Log( "*****\n" );
    Log( "***** WLN CLI program\n" );
    Log( "*****\n" );

    sei();

    counter = 0;
    while ( 1 )
    {
        LED_PORT ^= LED_MASK;

        if ( doStatus )
        {
            if ( counter == 0 )
            {
                uint8_t status = WLN_ReadStatus();
                WLN_PrintStatus( status );
            }
            counter = ( counter + 1 ) & 0x03;
        }

        // Tick rate is 100/sec so waiting for 50 waits for 1/2 sec

        for ( delay = 0; delay < 50; delay++ ) 
        {
            tick_t prevCount = gTickCount;
            while ( gTickCount == prevCount )
            {
                LogBufDump();
            }

            if ( UART0_IsCharAvailable() )
            {
                char    ch = UART0_GetChar();

                switch ( ch )
                {
                    case '!':
                    {
                        doStatus = !doStatus;
                        Log( "Turning status %s\n", doStatus ? "on" : "off" );
                        break;
                    }

                    case '*':
                    {
                        Log( "Reset\n" );

                        SetDirectionOut( RESET );
                        RESET_PORT &= ~RESET_MASK;
                        break;
                    }

                    case ' ':
                    {
                        WLN_ReadData();
                        break;
                    }

                    default:
                    {
                        Log( "Read: '%c'\n", ch );
                        WLN_WriteByte( ch );
                        break;
                    }
                }

            }
        }
    }

} // main
Esempio n. 30
0
/*
    Conditions:
      9
    Exit points:
      0
    M = 9 - 0 + 2 = 11
    Cyclomatic complexity
      11
  */
void Fingerprint_Task(void* arg)
{
  //TickType_t lastWake = 0;
  Packet_t packet, response;
  uint32_t i = 0;

  UNUSED_ARG(arg);

  InitLCD();
  InitUART();

  BSP_LCD_Clear(LCD_COLOR_WHITE);
  BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
  BSP_LCD_SetBackColor(LCD_COLOR_WHITE);

  gt511_startup();

  response.Data = NULL;
  response.Length = 0;
  packet.Data = NULL;
  packet.Length = 0;

  //*
  //fp_test();
  // */

  while (1)
  {
    BSP_LCD_ClearStringLine(2);
    BSP_LCD_DisplayStringAtLine(2, (uint8_t*)"Waiting on PC");

    i = 0;

    while (xQueueReceive(ctrlDataQueue.Rx, &packet, 500) != pdTRUE)
    {
      i += 1;

      BSP_LCD_ClearStringLine(2);

      switch (i & 3)
      {
        default:
        case 0:
          BSP_LCD_DisplayStringAtLine(2, (uint8_t*)"Waiting on PC");
          break;
        case 1:
          BSP_LCD_DisplayStringAtLine(2, (uint8_t*)"Waiting on PC.");
          break;
        case 2:
          BSP_LCD_DisplayStringAtLine(2, (uint8_t*)"Waiting on PC..");
          break;
        case 3:
          BSP_LCD_DisplayStringAtLine(2, (uint8_t*)"Waiting on PC...");
          break;
      }
    }

    fp_handle_packet(&packet, &response);

    if (response.Data != NULL)
      while (xQueueSendToBack(ctrlDataQueue.Tx, &response, -1) != pdTRUE);

    packet_free(&packet);

    response.Data = NULL;
    response.Length = 0;
    packet.Data = NULL;
    packet.Length = 0;

    BSP_LCD_Clear(LCD_COLOR_WHITE);
  }
}