int main() { UINT8 pinvalue; DRVCTRL example; drvinit(example); pinvalue = gpio_read_pin(&example,PORTD, 1); init_gpio(DRV_PORTB); init_gpio(DRV_PORTD); /* I would really like to be able to implement a function where I could just pass a pointer to a function that would be called when the timer overflowed, like the one below. */ /* schedulePeriodicTask(timePeriod,&task); */ init_timer(); init_usart0(); init_eeprom(); while (1) { ; } }
int main ( void ) { char *rstr = (char*) alloca(sizeof(char) * 128); //allocate an array of 128 bytes called rstr uint8_t cnt=0; //counter variable for(cnt=0; cnt<128; cnt++) { rstr[cnt] = 0; //clear out variable } init_usart0(51, DB8 | P_N | SB1); //51 is the ubrr value for 19.2kBaud at 16MHz and data format is 8N1 write_0s("This is a string of data!\r", 26); //Transmit this 26 byte string over the usart write_0s("Enter a string: ", 16); //Transmit this 16 byte string read_0s((uint8_t*)rstr, 128, '\r'); //read 128 bytes or until a '\r' is received (the enter button) ans store in str write_0s("You entered: ", 13); //write a string write_0s(rstr, strlen(rstr)); //write the received message while (1) ; return 0; }
/****************************************************************************** * MAIN * ******************************************************************************* * Description: Firmware Project start. This project: * (1) blinks the Mavric LED every .5 seconds * * Arguments: None * * Return: None ******************************************************************************/ int main(void) { ptrRxBufStart = 0; ptrRxBufEnd = 0; ptrCmdBuf = 0; rxBuf[0] = '\0'; init_timers(); init_usart0(); init_twi(); // enable printf stdout=stdin=&uartstr; // enable interrupts sei(); initMux(); DDRB = 0x01; // enable PORTB 1 as an output (LED) printf("\r\n\r\nAerosole Devices Manufacturing Test Program\r\n"); displaySerialCmdHelp(); printf(">"); while (1) { // blink LED if time has elapsed if(ms_count > 250) { ms_count = 0; toggleLED(); } getCommandData(); } return 0; }