Пример #1
0
void gpsNmeaTest(void)
{
	// set the baud rate of UART 1 for NMEA
	uartSetBaudRate(1,4800);

	// clear screen
	vt100ClearScreen();
	// initialize gps library
	gpsInit();
	// initialize gps packet decoder 
	nmeaInit();

	// begin gps packet processing loop
	while(1)
	{
		// process received gps packets until receive buffer is exhausted
		while( nmeaProcess(uartGetRxBuffer(1)) );

		// set cursor position to top left of screen
		vt100SetCursorPos(0,0);
		// print/dump current formatted GPS data
		gpsInfoPrint();
		// print UART 1 overflow status to verify that we're processing packets
		// fast enough and that our receive buffer is large enough
		rprintf("Uart1RxOvfl: %d\r\n",uartRxOverflow[1]);
		// pause for 100ms
		timerPause(100);
	}
}
Пример #2
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	// set the baud rate of the UART for our debug/reporting output
	uartSetBaudRate(9600);
	// initialize the timer system
	timerInit();

	// initialize rprintf system
	// - use uartSendByte as the output for all rprintf statements
	//   this will cause all rprintf library functions to direct their
	//   output to the uart
	// - rprintf can be made to output to any device which takes characters.
	//   You must write a function which takes an unsigned char as an argument
	//   and then pass this to rprintfInit like this: rprintfInit(YOUR_FUNCTION);
	rprintfInit(uartSendByte);

	// initialize vt100 library
	vt100Init();
	
	// clear the terminal screen
	vt100ClearScreen();
	
	// run the test
	rprintfTest();

	return 0;
}
Пример #3
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	uartSetBaudRate(115200);
	// make all rprintf statements use uart for output
	rprintfInit(uartSendByte);
	// initialize the timer system
	timerInit();
	// initialize vt100 terminal
	vt100Init();

	timerPause(100);

	// print welcome message
	vt100ClearScreen();
	vt100SetCursorPos(1,0);
	rprintfProgStrM("\r\nWelcome to the MMC Test Suite!\r\n");

	timerPause(1000);

	mmcTest();

	return 0;
}
Пример #4
0
void sabertooth(int m1, int m2)
	{
	//rprintfInit(uart2SendByte);//select uart2
	uartSetBaudRate(2, 38400);//select baud (see page 13/14 of datasheet)
	uart2SendByte(m1);//send a command for motor 1
	uart2SendByte(m2);//send a command for motor 2
	}
Пример #5
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	uartSetBaudRate(9600);
	// make all rprintf statements use uart for output
	rprintfInit(uartSendByte);
	// turn on and initialize A/D converter
	a2dInit();
	// initialize the timer system
	timerInit();
	// initialize vt100 terminal
	vt100Init();

	// configure port B for led output and pushbutton input
	outb(DDRB, 0x0F);
	// all LEDs on
	outb(PORTB, 0x00);
	// wait for hardware to power up
	timerPause(100);
	// all LEDs off
	outb(PORTB, 0x0F);

	// start command line
	goCmdline();

	return 0;
}
Пример #6
0
// functions
void oscInit(void)
{
	// initialize uart (if not already done)
	uartInit();
	// set the default communication rate
	uartSetBaudRate(38400);
}
Пример #7
0
/******************************************************************************
*   Functions
******************************************************************************/
void uartDataTaskInit(void)
{
	// Initialization of communication
	uartInit();
	uartSetBaudRate(115200);
	stdout = &mystdout;
}
Пример #8
0
// enable and initialize the uart
void uartInit(void)
{
	// initialize the buffers
	uartInitBuffers();
	// initialize user receive handler
	UartRxFunc = 0;

#if USE_2X
	sbi(UCSRA, U2X);
#else
	cbi(UCSRA, U2X);
#endif

	// enable RxD/TxD and interrupts
	//outb(UCSRB, BV(RXCIE)|BV(TXCIE)|BV(RXEN)|BV(TXEN));
	outb(UCSRB, BV(RXCIE)|BV(RXEN)|BV(TXEN));
	outb(UCSRC, BV(UCSZ1)|BV(UCSZ0)); /* 8 data bits, 1 stop bit */

	// set default baud rate
	uartSetBaudRate(UART_DEFAULT_BAUD_RATE);
	// initialize states
	//uartReadyTx = TRUE;
	//uartBufferedTx = FALSE;
	// clear overflow count
	uartRxOverflow = 0;
	// enable interrupts
	sei();
}
Пример #9
0
Файл: uart.c Проект: sndae/b3r1
// enable and initialize the uart
void uartInit(void)
{
	// initialize the buffers
	uartInitBuffers();
	// initialize user receive handler
	UartRxFunc = 0;

	// enable RxD/TxD and interrupts
	UCR = (1<<RXCIE)|(1<<TXCIE)|(1<<RXEN)|(1<<TXEN);

	//#ifdef UCSRA
	    // Make sure 2x speed is off -JR
	//	UCSRA &= ~(1<<U2X); 
	//#endif

	// set default baud rate
	uartSetBaudRate(UART_DEFAULT_BAUD_RATE);  
	// initialize states
	uartReadyTx = TRUE;
	uartBufferedTx = FALSE;
	// clear overflow count
	uartRxOverflow = 0;
	// enable interrupts
	sei();
}
Пример #10
0
void setup() {
  uartInit();
  uartSetBaudRate(0, 9600);
  rprintfInit(uart0SendByte);
  //rprintf("$Id$");

  // this goes to the switch common
  sbi(DDRD, PD4); // output on PD4
  cbi(PORTD, PD4); // take it low


  // rocker
  cbi(DDRD, PD5); // input on PD5
  sbi(PORTD, PD5); // tri-state the input

  // rocker
  cbi(DDRD, PD6);
  sbi(PORTD, PD6); // tri-state the input

  // rocker press
  cbi(DDRD, PD7);
  sbi(PORTD, PD7);

  sbi(DDRB, PB3); // output for the LED
  sbi(PORTB, PB3);
 }
Пример #11
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	// set the baud rate of UART 0 for our debug/reporting output
	uartSetBaudRate(0,9600);
	// set uart0SendByte as the output for all rprintf statements
	rprintfInit(uart0SendByte);
	// initialize the timer system
	timerInit();
	// initialize vt100 library
	vt100Init();
	
	// print a little intro message so we know things are working
	vt100ClearScreen();
	rprintf("\r\nWelcome to GPS Test!\r\n");
	
	// run example gps processing loop
	// (pick the one appropriate for your GPS packet format)
//	gpsTsipTest();
	gpsNmeaTest();
	
	return 0;
}
Пример #12
0
void setup() {
  uartInit();
  uartSetBaudRate(0, 9600);
  rprintfInit(uart0SendByte);
  rprintf("Hello..\r\n");
  //vt100Init();


  cbi(DDRC, DDC3); // input 

  cbi(DDRA, DDA0); // input
  cbi(DDRA, DDA1); // input
  cbi(DDRA, DDA2); // input
  cbi(DDRA, DDA3); // input
  cbi(DDRA, DDA4);
  
  sbi(DDRA, DDA5); // output connected by select to PA4
  cbi(PORTA, PA5);
  
  sbi(PORTA, PA0); // pull-ups enabled
  sbi(PORTA, PA1);
  sbi(PORTA, PA2);
  sbi(PORTA, PA3);
  sbi(PORTA, PA4);
  cbi(PORTA, PA5);
  

  cbi(DDRD, DDD6); // input
  //cbi(PORTB, PB3);

  // We want PCINT30 enabled so we know when the charger is connected
  //  PCICR |= (1<<PCIE3); // enable pin change interrupt 3 for PCINT31..24. 
//  PCMSK3 |= 0xFF;//(1<<PCINT30); // enable PCINT30

  // arb switch
  PCICR |= (0<<PCIE3) | (0<<PCIE2) | (0<<PCIE1) | (1<<PCIE0);
  //  PCMSK3 |= (1<<PCINT30);
  //  PCMSK3 |= (1<<PCINT26);
  //  PCMSK2 |= (1<<PCINT19);
  PCMSK0 |= (1<<PCINT0) | (1<<PCINT1) | (1<<PCINT2) | (1<<PCINT3) | (1<<PCINT4) | (1<<PCINT5);


  // set up the power pulse LED
  
  TCCR0A |= (1<<WGM00) | (1<<COM0A1); // mode 1, phase-correct PWM
  TCCR0B |= (1<<CS02); // clk/256 from prescaler
  //TCCR0B |= (0<<CS02) | (1<<CS01) | (1<<CS00); // clk/64

  TCNT0 = 0x00;
  sbi(TIMSK0, TOIE0);

  sbi(DDRB, PB3);
  sbi(PORTB, PB3);
/*
  cbi(DDRD, PD6); // configure PD6 as input
  sbi(PORTD, PD6); // turn on pull-up resistor
*/
  sei();
}
Пример #13
0
void initUart(void)
{
	uartInit();
	 // make all rprintf statements use uart for output
	rprintfInit(uartSendByte);
	 // initialize the timer system
	uartSetBaudRate(2400);
}
void open_log_init(void) {
    uart1Init();
    uartSetBaudRate(1,9600);
    
	OPEN_LOG_PWR_PORT &= ~(1<<OPEN_LOG_PWR_PIN);
	DDR(OPEN_LOG_PWR_PORT) |= (1<<OPEN_LOG_PWR_PIN);
	
	//	setup our reset port and pin, hold reset high
	OPEN_LOG_RESET_PORT |= (1<<OPEN_LOG_RESET_PIN);
	DDR(OPEN_LOG_RESET_PORT) |= (1<<OPEN_LOG_RESET_PIN);
}
Пример #15
0
void main(void)
{
	struct tm* t = NULL;
	char buf[32];
	uint8_t hour, min, sec;

	uartInit();
	uartSetBaudRate(9600);
	uartSendString("DS RTC Library Test\n");

	LED_DDR  |= _BV(LED_BIT); // indicator led

	for (int i = 0; i < 5; i++) {
		LED_HIGH;
		_delay_ms(100);
		LED_LOW;
		_delay_ms(100);
	}

	uartSendString("Before Init\n");
	twi_init_master();
	rtc_init();
	rtc_set_time_s(12, 0, 50);

	uartSendString("After Init\n");
	if (rtc_is_ds1307())
		uartSendString("DS1307\n");
	else
		uartSendString("DS3231\n");

	rtc_set_alarm_s(12, 1, 0);
	
	rtc_get_alarm_s(&hour, &min, &sec);

	sprintf(buf, "Alarm is set -%d:%d:%d-\n", hour, min, sec);
	uartSendString(buf);	
	uartSendString("---\n");
	uartSendString("---\n");
	uartSendString("---\n");

	while (1) {
		t = rtc_get_time();

		sprintf(buf, "%d:%d:%d\n", t->hour, t->min, t->sec);
		uartSendString(buf);
		uartSendString("---\n");

		if (rtc_check_alarm())
			uartSendString("ALARM!\n");

	   	_delay_ms(500);
	}
}
Пример #16
0
void init_peripherals()
{

	// LED
	DDRC |= (1<<2);

	// accel pins
	lis3l_init();



	// UART
	uartInit();
	uartSetBaudRate(19200);
	uartSetFrameFormat(8, 0, 1);
	rprintfInit(uartAddToTxBuffer);
	cbi(DDRB, 1);		// XBee CTS on PB1 


	// I2C
	itg3200_i2cInit(200);
	sbi(PORTC, 0);	// i2c SCL on ATmega163,323,16,32,etc
	sbi(PORTC, 1);	// i2c SDA on ATmega163,323,16,32,etc
	cbi(TWCR, TWIE); // disable interrupt
//	itg3200_i2cSetBitrate(200); // todo, check if if w ecan do 200

	// SPI
	mySpiInit();

	// a2d
	a2dInit();
	a2dSetReference(ADC_REFERENCE_256V);
	a2dSetChannel(7);
	cbi(PORTA, 7);
	cbi(DDRA, 7);
	a2dStartConvert();

	_delay_ms(50);

	// accel
	BOOL accelOkay = lis3l_Reset();
	itg3200_init();


	// switch xbee to higher baudrate
//	rprintfStr("+++");
//	_delay_ms(55);
//	rprintfStr("ATBD6,CN\r");

}
Пример #17
0
void setup() {
  uart0Init();
  uartSetBaudRate(0, 9600);
  rprintfInit(uart0SendByte);
  //rprintf("Hello.."); rprintfCRLF();
  rprintf("$Id: psp_joystick.c,v 1.1.1.1 2007/08/21 05:14:23 julian Exp $");
  vt100Init();

  sbi(DDRD, DDD4); // output PD4
  sbi(PORTD, PD4); // set it high
  cbi(DDRD, DDD5); // input PD5
  sbi(PORTD, PD5); // set it low

  cbi(DDRA, DDA0); // input (one axis)
  cbi(DDRA, DDA1); // input (the other axis)
  //cbi(DDRA, DDA2); // input
  //sbi(DDRA, DDA3); // output
  //sbi(PORTA, PA0);
  //sbi(PINA, PINA0); // set high
  //sbi(PINA, PA3);
  a2dInit();

  // set up the power pulse LED
  TCCR0A |= (1<<WGM00) | (1<<COM0A1); // mode 1, phase-correct PWM
  TCCR0B |= (1<<CS02); // clk/256 from prescaler
  //TCCR0B |= (0<<CS02) | (1<<CS01) | (1<<CS00); // clk/64

  // set up and enable the power pulse thing
  TCNT0 = 0x00;
  sbi(TIMSK0, TOIE0);

  sbi(DDRB, DDB3); // output on the LED
  sbi(PORTB, PB3); // turn it on
  u08 i, j;
  for(j=0; j<1; j++) {
  for(i=0; i<10; i++) {
  	_delay_ms(32);
  }
  cbi(PORTB, PB3);
  for(i=0; i<10; i++) {
  	_delay_ms(32);
  }
  sbi(PORTB, PB3);
  for(i=0; i<10; i++) {
	  _delay_ms(32);
  }
  }
  cbi(PORTB, PB3);
  sei();
}
int main(void)
{
	uartInit();
	uartSetBaudRate(115200);
	rprintfInit(uartSendByte);

	a2dInit();
	timerInit();
	vt100Init();




	return 0;
}
Пример #19
0
int main(void)
{
	timerInit();				// initializing timers
	uartInit();					// initializing serial port
	uartSetBaudRate(115200);	// set serial port baud rate
	rprintfInit(uartSendByte);	// direct rprintf() output to go to serial port
	timerPause(100);			// wait for a moment

	// print welcome message
	rprintf("\r\n\n\nWelcome to the Spyglass UI test.\r\n");

	// begin test application
	spyglassTest();

	return 0;
}
Пример #20
0
void uart1Init(void) {
	// initialize the buffers
	uart1InitBuffers();
	// initialize user receive handlers
	UartRxFunc[1] = 0;
	// enable RxD/TxD and interrupts
	outb(UCSR1B, BV(RXCIE1)|BV(TXCIE1)|BV(RXEN1)|BV(TXEN1));
	// set default baud rate
	uartSetBaudRate(1, UART1_DEFAULT_BAUD_RATE);
	// initialize states
	uartReadyTx[1] = TRUE;
	uartBufferedTx[1] = FALSE;
	// clear overflow count
	uartRxOverflow[1] = 0;
	// enable interrupts
	sei();
}
Пример #21
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	// set the baud rate of the UART for our debug/reporting output
	uartSetBaudRate(115200);
	// initialize rprintf system
	rprintfInit(uartSendByte);
	// initialize timers
	timerInit();
	
	// run the test
	extintTest();

	return 0;
}
Пример #22
0
void uart0Init(void)
{
	// initialize the buffers
	uart0InitBuffers();
	// initialize user receive handlers
	UartRxFunc[0] = 0;
	// enable RxD/TxD and interrupts
	outb(UCSR0B, _BV(RXCIE)|_BV(TXCIE)|_BV(RXEN)|_BV(TXEN));
	// set default baud rate
	uartSetBaudRate(0, UART0_DEFAULT_BAUD_RATE); 
	// initialize states
	uartReadyTx[0] = 1;
	uartBufferedTx[0] = 0;
	// clear overflow count
	uartRxOverflow[0] = 0;
	// enable interrupts
	sei();
}
Пример #23
0
void init_uart(void) {
    // initialize our libraries
    // initialize the UART (serial port)
    uartInit();
    // set the baud rate of the UART for our debug/reporting output
    uartSetBaudRate(9600);
    // set uartSendByte as the output for all rprintf statements
    rprintfInit(uartSendByte);
    // initialize the timer system
    timerInit();
    // initialize vt100 library
    vt100Init();
    vt100ClearScreen();
    // print a little intro message so we know things are working
    rprintf("\r\nServo tester\r\n");
    rprintf("Sebastien CELLES\r\n");
    rprintf("IUT de Poitiers\r\n");
    rprintf("Genie Thermique et Energie\r\n");
}
Пример #24
0
void uart1Init(void)
{
	// initialize the buffers
	uart1InitBuffers();
	// initialize user receive handlers
	UartRxFunc[1] = 0;
	// enable RxD/TxD and interrupts
	// use (UDRIEn) bit in UCSRnB instead of TXCIE
	// no TXCIE interrupt since we've got nothing to transmit right now.
	outb(UCSR1B, _BV(RXCIE)|_BV(RXEN)|_BV(TXEN));
	// set default baud rate
	uartSetBaudRate(1, UART1_DEFAULT_BAUD_RATE);
	// initialize states
	uartBufferedTx[1] = FALSE;
	// clear overflow count
	uartRxOverflow[1] = 0;
	// enable interrupts
	sei();
}
Пример #25
0
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	// set the baud rate of the UART for our debug/reporting output
	uartSetBaudRate(9600);
	// set uartSendByte as the output for all rprintf statements
	rprintfInit(uartSendByte);
	// initialize the timer system
	timerInit();

	// print a little intro message so we know things are working
	rprintf("\r\nWelcom to Servo Test!\r\n");

	// being servo test
	servoTest();

	return 0;
}
Пример #26
0
// enable and initialize the uart
void uartInit(void)
{
	// initialize the buffers
	uartInitBuffers();
	// initialize user receive handler
	UartRxFunc = 0;

	// enable RxD/TxD and interrupts
	outb(UCR, BV(RXCIE)|BV(TXCIE)|BV(RXEN)|BV(TXEN));

	// set default baud rate
	uartSetBaudRate(UART_DEFAULT_BAUD_RATE);  
	// initialize states
	uartReadyTx = TRUE;
	uartBufferedTx = FALSE;
	// clear overflow count
	uartRxOverflow = 0;
	// enable interrupts
	sei();
}
Пример #27
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	uartSetBaudRate(115200);
	// make all rprintf statements use uart for output
	rprintfInit(uartSendByte);
	// initialize the timer system
	timerInit();
	// clear terminal screen
	vt100ClearScreen();
	vt100SetCursorPos(1,1);
	// print a little intro message so we know things are working
	rprintf("\r\nWelcome to ADS7828 test!\r\n");
	
	// run tests
	ads7828test();

	return 0;
}
Пример #28
0
//----- Begin Code ------------------------------------------------------------
int main(void)
{
	// initialize our libraries
	// initialize the UART (serial port)
	uartInit();
	// set the baud rate of the UART for our debug/reporting output
	uartSetBaudRate(9600);
	// initialize the timer system
	timerInit();
	// initialize rprintf system
	rprintfInit(uartSendByte);
	// initialize vt100 library
	vt100Init();

	// clear the terminal screen
	vt100ClearScreen();
	
	// run the test
	encoderTest();

	return 0;
}
Пример #29
0
void init(void)
{
   // Initialize Timer
   timerInit();
   // Initialize LCD
   lcdInit();
   ourLcdControlWrite(1<<LCD_ON_CTRL | 1<<LCD_ON_DISPLAY);
   // Initialize UART
	uartInit();
	uartSetBaudRate(CMU_BAUD);
	uartSetRxHandler(packetRcv);
   rprintfInit(uartSendByte);
   // Initialize PWM
   outb(DDRD, 0xFF);	// set all port D pins to output
   timer1PWMInit(8);
	timer1PWMAOn();
   timer1PWMBOn();
   // Initialize  Servos
   servoInit();
   // Initialize CMU
   lcdWriteStr("CMUcam2 init", 0, 0);
   cmuInit();
}
Пример #30
0
void setup() {

  uart0Init();
  uartSetBaudRate(0, 9600);
  rprintfInit(uart0SendByte);
  rprintf("$Id$");

  // this goes to the switch common
  sbi(DDRA, DDA0); // output on PA0
  sbi(PORTA, PA0); // take it high

  cbi(DDRA, DDA1); 
  cbi(DDRA, DDA2);
  cbi(DDRA, DDA3);
  cbi(DDRA, DDA4);
  cbi(DDRA, DDA5);

  a2dInit();
  a2dSetReference(ADC_REFERENCE_AVCC);
  a2dSetPrescaler(ADC_PRESCALE_DIV128);

  sbi(DDRB, PB3); // output for the LED
  sbi(PORTB, PB3);
 }