📄 smain._c
字号:
#include "sci.h"
#include "modem.h"
#include <stdlib.h>
unsigned char disgga[]={
0XB5,0x62,0x06,0x01,0x06,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0xFD,0x15// CANCEL GGA
};
unsigned char disgll[]={
0xB5,0x62,0x06,0x01,0x06,0x00,0xF0,0x01,0x00,0x00,0x00,0x00,0xFE,0x1A//,CANCEL GLL
};
unsigned char disgsa[]={
0xB5,0x62,0x06,0x01,0x06,0x00,0xF0,0x02,0x00,0x00,0x00,0x00,0xFF,0x1F// CANCEL GSA
};
unsigned char disgsv[]={
0XB5,0x62,0x06,0x01,0x06,0x00,0xF0,0x03,0x00,0x00,0x00,0x00,0x00,0x24// CANCEL GSV
};
unsigned char disvtg[]={
0xB5,0x62,0x06,0x01,0x06,0x00,0xF0,0x05,0x00,0x00,0x00,0x00,0x02,0x2E// CANCEL VTG
};
unsigned char disgrs[]={
0XB5,0x62,0x06,0x01,0x06,0x00,0xF0,0x06,0x00,0x00,0x00,0x00,0x03,0x33// CANCEL GRS
};
unsigned char disgst[]={
0xB5,0x62,0x06,0x01,0x06,0x00,0xF0,0x07,0x00,0x00,0x00,0x00,0x04,0x38// CANCEL GST
};
unsigned char diszda[]={
0XB5,0x62,0x06,0x01,0x06,0x00,0xF0,0x08,0x00,0x00,0x00,0x00,0x05,0x3D// CANCEL ZDA
};
void setGPS(BYTE *command){
BYTE *p,i;
p = command;
for (i = 0;i < 14;i ++){
WriteComm0( *p );
p ++;
}
DelayMORE(10);
}
void iniGPS(){
setGPS(disgga);
setGPS(disgll);
setGPS(disgsa);
setGPS(disgsv);
setGPS(disvtg);
setGPS(disgrs);
setGPS(disgst);
setGPS(diszda);
}
void port_init(void)
{
PORTA = 0x04;
DDRA = 0x04;//speaker
PORTB = 0x01;
DDRB = 0x01;
PORTC = 0x00;
DDRC = 0x00;
PORTD = 0x00;
DDRD = 0x00;
DDRD |= BIT(STA);
DDRD |= BIT(STC);
}
//UART0 initialize
// desired baud rate: 9600
// actual: baud rate:9600 (0.0%)
// char size: 8 bit
// parity: Disabled
void uart0_init(void)
{
UCSR0B = 0x00; //disable while setting baud rate
UCSR0A = 0x00; //disable while setting baud rate
UBRR0L =0x17; //set baud rate
UBRR0H = 0x00;
UCSR0C = BIT(URSEL0) | 0x06;
UCSR0A = 0x00; //enable
//UCSR0B = 0x18; //enable
UCSR0B = (1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0);
setCommEventProc(ProcModemReceive);
}
//UART1 initialize
// actual baud rate:9600 (0.0%)
// char size: 8 bit
// parity: Disabled
void uart1_init(void)
{
UCSR1B = 0x00; //disable while setting baud rate
UCSR1A = 0x00; //disable while setting baud rate
UBRR1L =0x17; //set baud rate
UBRR1H = 0x00;
UCSR1C = BIT(URSEL1) | 0x06;
UCSR1A = 0x00; //enable
//UCSR1B = (1<<RXEN1)|(1<<TXEN1)|(1<<RXCIE1);
UCSR1B = (1<<RXEN1)|(1<<TXEN1);
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
uart0_init();
uart1_init();
MCUCR= 0x00; //mcu control register
EMCUCR = 0x00;//extend ect
//GIMSK= 0x00;
TIMSK= 0x00; //timer interrupt sources
ETIMSK=0x00;
GICR= 0x00;//general interrupt control register
PCMSK0=0x00;
PCMSK1=0x00;
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -