本文整理汇总了C++中UART_BAUD_SELECT函数的典型用法代码示例。如果您正苦于以下问题:C++ UART_BAUD_SELECT函数的具体用法?C++ UART_BAUD_SELECT怎么用?C++ UART_BAUD_SELECT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UART_BAUD_SELECT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
uint8_t escaped = 0;
leds_init();
DDR_CONFIG_OUT(RS485_TX_PIN);
DDR_CONFIG_OUT(RS485_NRX_PIN);
PIN_CLEAR(RS485_TX_PIN);
PIN_CLEAR(RS485_NRX_PIN);
UBRR0 = UART_BAUD_SELECT(RS485_BITRATE,F_CPU);
UCSR0B |= (1<<TXEN0) | (1<<RXEN0);
UBRR1 = UART_BAUD_SELECT(RS485_BITRATE,F_CPU);
UCSR1B |= (1<<TXEN1) | (1<<RXEN1);
wdt_reset();
PIN_SET(RS485_TX_PIN);
PIN_SET(RS485_NRX_PIN);
while(1){
wdt_reset();
if( (UCSR1A & (1<<RXC1)) ){
uint8_t data = UDR1;
if( escaped ){
escaped = 0;
if( data == 'R' ){
wdt_enable(WDTO_2S);
while(1);
}
}else{
if( data == '\\' ){
escaped = 1;
continue;
}
}
UDR0 = data;
PIN_SET(RS485_TX_PIN);
PIN_SET(RS485_NRX_PIN);
//_delay_us(4);
leds_tx();
while( !(UCSR0A & (1<<TXC0)) );
UCSR0A |= (1<<TXC0);
leds_txend();
//_delay_us(4);
PIN_CLEAR(RS485_TX_PIN);
PIN_CLEAR(RS485_NRX_PIN);
}
if( (UCSR0A & (1<<RXC0)) ){
UDR1 = UDR0;
leds_rx();
while( !(UCSR1A & (1<<TXC1)) );
UCSR1A |= (1<<TXC1);
leds_rxend();
}
}
}
示例2: init
static void init(void) {
clock_prescale_set(clock_div_1);
uart_init(UART_BAUD_SELECT(BAUD, F_CPU));
uart1_init(UART_BAUD_SELECT(BAUD, F_CPU));
fdev_setup_stream(&mystdout, _uart_putc, NULL, _FDEV_SETUP_WRITE);
fdev_setup_stream(&mystdout1, _uart1_putc, NULL, _FDEV_SETUP_WRITE);
stdout = &mystdout;
DDRD |= _BV(PIND6);
DDRE |= _BV(PINE3);
}
示例3: main
int main(void) {
// init
uart_init(UART_BAUD_SELECT(UART_BAUD_RATE, F_CPU));
// enable interrupts after resetting the kicker
sei();
uart_puts_P("* Interrupts enabled. - ");
ports_init();
uart_puts_P("Ports initialized. - ");
kicker_init();
uart_puts_P("Kicker initialized. - ");
//kicker_uext(500);
uart_puts_P("Device initialized. Enter main loop\n");
for (;;) {
parser_process_uart();
}
return 0;
}
示例4: main
int main(void)
{
uart_config_default_stdio();
uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );
spi_init();
radio_init();
sei();
printf("\nTX Test. Type in a packet:\n");
txtest_configure_radio();
//====================//
//Communications Test
char temp;
temp = rfm22b_read(DTYPE);
temp = rfm22b_read(DVERS);
temp = rfm22b_read(INTEN1);
temp = rfm22b_read(INTEN2);
temp = rfm22b_read(OMFC1);
temp = rfm22b_read(OMFC2);
while(1)
{
txtest_fill_packet_from_uart();
txtest_send_current_packet();
printf("Transmit done. Type another:\n\n");
}
}
示例5: uart_init
// Initialize uart and direct standard out and standard error to uart
void Debug::Initialize()
{
uart_init(UART_BAUD_SELECT(UART_BAUD_RATE, F_CPU));
fdev_setup_stream(&uartStream, UARTPutChar, NULL, _FDEV_SETUP_WRITE);
stdout = &uartStream;
stderr = &uartStream;
}
示例6: init
void init(void) {
// configure pins
DDRB |= (1 << DSKY_DISPLAY_PIN_CLR); // output
DDRD |= (1 << DSKY_DISPLAY_PIN_PWRCLR); // output
DDRD &= ~(1 << DSKY_DISPLAY_PIN_PWRCLR);
// configure pins for SPI master
SPI_init();
// initialize UART
uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );
// intialize KSP plugin
kspio_init();
clearRegisters(); // resets the shift registers and the decade counter
// initialize bargraph PWM pins as outputs
DSKY_BARGRAPH_CTRL_PORT |= (1 << DSKY_BARGRAPH_PIN_B1);
DSKY_BARGRAPH_CTRL_PORT |= (1 << DSKY_BARGRAPH_PIN_B2);
DSKY_BARGRAPH_CTRL_PORT |= (1 << DSKY_BARGRAPH_PIN_B3);
// configure PWMs for bargraph displays
TCCR0A |= (1 << COM0A1); // set non-inverting mode for OC0A
TCCR0A |= (1 << COM0B1); // set non-inverting mode for OC0B
TCCR0A |= (1 << WGM01) | (1 << WGM00); // set fast PWM mode
TCCR0B |= (1 << CS02) | (1 << CS00); // set prescaler to 1024 and start PWM
TCCR2A |= (1 << COM2B1); // set non-inverting mode for OC2B
//TCCR2A |= (1 << WGM21) | (1 << WGM20); // set fast PWM mode - done in millis.c
//TCCR2B |= (1 << CS22) | (1 << CS21) | (1 << CS20); // set prescaler to 1024 and start PWM - done in millis.c
// multiplexing the displays
TCCR1A |= (1 << WGM10); // timer/counter control register 1 A: fast PWM
TCCR1B |= (1<<WGM12) | (1<<CS11) | (1<<CS10); // timer/counter control register 1 B: clock select 64th frequency
TIMSK1 |= (1<<TOIE1); // timer/counter interrupt mask register: timer/counter 1 overflow interrupt enable
}
示例7: init_hw
/**
* Initiate hardware peripherials.
*/
void init_hw() {
ARD_LED_INIT(); // init arduino LED port
uart_init(UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU)); // init uarts
stdout = &mystdio; // configure stdout to UART 0
TIMER0_PRES_1024(); // set prescaler of timer 0
TIMER0_OVF_IE(); // enable overflow interrupt of timer 0
TIMER0_RELOAD(TIMER0_10MS); // reload counter of timer 0
TIMER1_PRES_1024(); // set prescaler of timer 1
TIMER1_OVF_IE(); // enable overflow interrupt of timer 1
TIMER1_RELOAD(TIMER1_CNT); // reload counter of timer 1
but.port = &PINB; // initiate button
but.bit = PB4;
button_init(&but, &PORTB);
LEF_TimerInit(&eTimer1);
LEF_TimerInit(&eTimer2);
LEF_TimerInit(&eTimer3);
LEF_TimerStartRepeat(&eTimer1, 100); // set as 100 ticks repeating timer
LEF_TimerStartRepeat(&eTimer2, 200); // set as 100 ticks repeating timer
sev_cmd_init(cmdTable);
sei(); // enable interrupts
}
示例8: GPS_init
void GPS_init() {
// Initialize UART:
// set baud rate
unsigned int baudrate = UART_BAUD_SELECT(GPS_UART_BAUDRATE,F_CPU);
if ( baudrate & 0x8000 )
{
GPS_UART_STATUS = (1<<U2X0); //Enable 2x speed
baudrate &= ~0x8000;
}
GPS_UART_UBRR = (unsigned char)baudrate;
/* enable UART receiver and transmmitter and receive complete interrupt */
GPS_UART_CONTROL = _BV(RXCIE0)|_BV(RXEN0)|_BV(TXEN0);
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
#ifdef GPS_UART_URSEL0
GPS_UART_MISC = (1<<URSEL0)|(3<<UCSZ00);
#else
GPS_UART_MISC = (3<<UCSZ00);
#endif
// Initialize state machine
GPS_state = 0;
}
示例9: main
int main(void){
DDRC = 0x00;
uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );
sei();
unsigned int c;
while(1){
c = uart_getc();
if(c & UART_NO_DATA){
/*
* NO UART DATA available
*/
}
else{
/*
* New Data is avialable at the port.
* check the frame for overrun errro
*/
if ( c & UART_FRAME_ERROR ){
/* Framing Error detected, i.e no stop bit detected */
uart_puts_P("UART Frame Error: ");
}
if ( c & UART_OVERRUN_ERROR ){
/*
*
* Overrun, a character already present in the UART UDR register was
*
* not read by the interrupt handler before the next character arrived,
* one or more received characters have been dropped
*
*
*/
uart_puts_P("UART Overrun Error: ");
}
if ( c & UART_BUFFER_OVERFLOW ){
/*
*
* We are not reading the receive buffer fast enough,
*
* one or more received character have been dropped
*
*/
uart_puts_P("Buffer overflow error: ");
}
processData(c);
// PORTC = c;
}
}
return 0;
}
示例10: main
int main(void)
{
// initializing uart data variables for storage of incoming data
// signed char uart_data_length = -1;
// char char1 = '@';
// int innt = 12412;
// long long1 = -123456789;
// float float1 = 3.1415926;
// double double1 = -2.81;
//
uart_init( UART_BAUD_SELECT(BAUD,F_CPU) );
TC1_Setup();
sei();
uart_putc(2);
mpu6050_setup();
uart_putc(3);
// DDRD = 0b11111011; // set PD2 to input
// PORTD = 0b00000100; // set PD2 to high
//
// EICRA = 0b00000011;
// EIMSK = 0b00000001;
// PCICR |= _BV(PCIE0); //Enable PCINT2
//
// PCMSK0 |= (1 << PCINT0); /* Enable PCINT0 */
DDRB |= 1 << PINB0;
while (1)
{
PORTB ^= 1 << PINB0;
_delay_ms(500);
}
}
示例11: main
int main(void)
{
double lat = 0.0, lon = 0.0;
char buffer[32];
uint16_t v;
AFSK_Init();
uart_init((UART_BAUD_SELECT(9600,F_CPU)));
Trigger_Init();
batv_init();
// Sleep control
DDRC |= (1<<PORTC0);
PORTC &= ~(1<<PORTC0);
// Debug led
DDRD |= (1<<PORTD3);
PORTD &= ~(1<<PORTD3);
// set_sleep_mode( SLEEP_MODE_PWR_DOWN );
// set_sleep_mode( SLEEP_MODE_IDLE );
sei();
sns_nmea_Init();
send=1;
for(;;) {
// sleep_enable();
// sleep_cpu();
// sleep_disable();
// c = uart_getc();
sns_nmea_Process();
// if( !(c&0xFF00) ) {
// PORTB ^= (1<<PORTB1);
// }
if( send ) {
// Convert to pengi friendly format
lat = (double)(NMEA_data.lat_deg) + (double)(NMEA_data.lat_min/60.0) + (double)(NMEA_data.lat_sec_h/6000.0);
lon = (double)(NMEA_data.lon_deg) + (double)(NMEA_data.lon_min/60.0) + (double)(NMEA_data.lon_sec_h/6000.0);
// end conversion
v = batv_get();
sprintf( buffer, "Vcc: %d.%02dV", v/100, v%100 );
aprs_packet_rewind( &pkt );
aprs_pack_position( &pkt, lat /*57.68111667*/, lon /*11.98611667*/, '/'<<8|'[' );
aprs_add_comment( &pkt, buffer );
ax25_tx_packet( &pkt );
sns_nmea_Init();
send = 0;
}
}
return 0;
}
示例12: initSerial
char initSerial(uint16_t baud)
{
switch(baud)
{
case 38400:
uart_init(UART_BAUD_SELECT(38400,F_CPU));
break;
case 9600:
uart_init(UART_BAUD_SELECT(9600,F_CPU));
break;
case 1200:
uart_init(UART_BAUD_SELECT(1200,F_CPU));
break;
default:
return(-1);
}
return 0;
}
示例13: main
int main() {
uart_init(UART_BAUD_SELECT(UART_BAUD_RATE, F_CPU));
sei();
uart_puts("begin\r\n");
nrfInit();
writeReg(RF_SETUP, SET_RF_SETUP);
writeAddr(RX_ADDR_P0, SET_RX_ADDR_P0);
writeAddr(TX_ADDR, SET_TX_ADDR);
writeReg(DYNPD, SET_DYNPD);
writeReg(FEATURE, SET_FEATURE);
writeReg(RF_CH, SET_RF_CH);
writeReg(CONFIG, SET_CONFIG);
startRadio();
uint8_t worked;
uint8_t size;
char sendbuffer[] = "Testing 1..2..3.. Testing.";
size = sizeof (sendbuffer);
char receivebuffer[33];
char c;
char count[10];
int charbuffer;
char payloadlength;
// uart_puts(sendbuffer);
worked = transmit(sendbuffer, size);
if (worked == 1) {
uart_puts("Transmit Worked!\r\n");
} else {
uart_puts("Transmit Failed.\r\n");
}
startRx();
while (1) {
payloadlength = dynReceive(receivebuffer);
if (payloadlength > 0) {
uart_puts("Got something:");
uart_puts(receivebuffer);
uart_puts("\r\n");
} else {
uart_puts("nothin received\r\n");
}
c = uart_getc();
if (!(c & UART_NO_DATA)) {
uart_putc(c);
}
printRegisters();
_delay_ms(2000);
}
}
示例14: main
int main(void)
{
uart_t *u0;
uint8_t rc;
rtc_device_t *rtc = &rtc_ds1307;
rtc_datetime_24h_t current_dt, offset_dt;
_delay_ms(1000);
u0 = uart_init("0", UART_BAUD_SELECT(38400, F_CPU));
uart_init_stdout(u0);
i2c_init();
DDRC = _BV(PC0) | _BV(PC1);
PORTC = _BV(PC0) | _BV(PC1);
sei();
printf("\n\nBooted up!\n");
rc = rtc_init(rtc);
printf("Inited RTC, rc=%i\n", rc);
rc = rtc_sqw_rate(rtc, 1);
printf("Set sqw rate, rc=%i\n", rc);
rc = rtc_sqw_enable(rtc);
printf("Set sqw enable, rc=%i\n", rc);
rc = rtc_clock_start(rtc);
printf("Started clock, rc=%i\n", rc);
_delay_ms(1000);
while(1)
{
rc = rtc_read(rtc, ¤t_dt);
rtc_offset_time(¤t_dt, &offset_dt, -7);
printf("rc = %i, %04i-%02i-%02i %02i:%02i:%02i %i offset: %04i-%02i-%02i %02i:%02i:%02i %i\n",
rc,
current_dt.year, current_dt.month, current_dt.date,
current_dt.hour, current_dt.minute, current_dt.second,
current_dt.day_of_week,
offset_dt.year, offset_dt.month, offset_dt.date,
offset_dt.hour, offset_dt.minute, offset_dt.second,
offset_dt.day_of_week
);
_delay_ms(1000);
}
return(0);
}
示例15: main
int main(void) {
InitLEDPort();
YellowLEDOn();
delay_sec(1);
YellowLEDOff();
delay_sec(1);
YellowLEDOn();
delay_sec(1);
i2c_init(); // init I2C interface
#ifdef UART_DEBUG
uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );
sei();
uart_puts_P("\r\n'lsm303test' ready!\r\n");
#endif // UART_DEBUG
#ifdef LSM303DLH_USE_ACC
LSM303DLHInitACC( I2C_DEV_LSM303DLH_ACC1 );
#endif // LSM303DLH_USE_ACC
#ifdef LSM303DLH_USE_MAG
LSM303DLHInitMAG( I2C_DEV_LSM303DLH_MAG );
#endif // LSM303DLH_USE_MAG
while ( 1 ) {
#ifdef UART_DEBUG
uart_puts_P("\r\nRunning test... ");
#endif // UART_DEBUG
#if (defined LSM303DLH_USE_ACC) || (defined LSM303DLH_USE_MAG)
# ifdef LSM303DLH_USE_ACC
LSM303DLHTestACC();
# endif // LSM303DLH_USE_ACC
# ifdef LSM303DLH_USE_MAG
LSM303DLHTestMAG();
# endif // LSM303DLH_USE_MAG
#else
# ifdef UART_DEBUG
uart_puts_p( cCRLF );
# endif // UART_DEBUG
delay_sec(2);
#endif // LSM303DLH_USE_ACC || LSM303DLH_USE_MAG
}
return 0;
}