Line 25... |
Line 25... |
25 |
#define BUF_LEN 4 |
25 |
#define BUF_LEN 4 |
26 |
int8 buffer[BUF_LEN]; // I2C buffer |
26 |
int8 buffer[BUF_LEN]; // I2C buffer |
27 |
int8 address=0; |
27 |
int8 address=0; |
28 |
|
28 |
|
29 |
unsigned int16 of=0; // count of overflow |
29 |
unsigned int16 of=0; // count of overflow |
30 |
|
- |
|
31 |
// 1x 100 us per 10 s UTC synchronised |
- |
|
32 |
const char cmd[40]={0xB5, 0x62, 0x06, 0x31, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x80, 0x96, 0x98, 0x00, 0xE0, 0xC8, 0x10, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0xC6, 0x51}; |
- |
|
33 |
|
30 |
|
- |
|
31 |
// configure GPS |
- |
|
32 |
void setup_GPS() |
- |
|
33 |
{ |
- |
|
34 |
// 1x 100 us per 10 s UTC synchronised |
- |
|
35 |
const char cmd[40]={0xB5, 0x62, 0x06, 0x31, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x80, 0x96, 0x98, 0x00, 0xE0, 0xC8, 0x10, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0xC6, 0x51}; |
- |
|
36 |
int n; |
- |
|
37 |
for (n=0;n<40;n++) putc(cmd[n]); |
- |
|
38 |
} |
- |
|
39 |
|
34 |
#INT_SSP |
40 |
#INT_SSP |
35 |
void ssp_interupt () |
41 |
void ssp_interupt () |
36 |
{ |
42 |
{ |
37 |
int8 incoming, state; |
43 |
int8 incoming, state; |
38 |
|
44 |
|
Line 74... |
Line 80... |
74 |
i2c_write(buffer[2]); // Prepare next byte to SSP buffer |
80 |
i2c_write(buffer[2]); // Prepare next byte to SSP buffer |
75 |
} |
81 |
} |
76 |
if(state == 0x83) //Master is requesting data |
82 |
if(state == 0x83) //Master is requesting data |
77 |
{ |
83 |
{ |
78 |
i2c_write(buffer[3]); // Prepare next byte to SSP buffer |
84 |
i2c_write(buffer[3]); // Prepare next byte to SSP buffer |
- |
|
85 |
|
- |
|
86 |
setup_GPS(); |
79 |
} |
87 |
} |
80 |
|
88 |
|
81 |
if(state > 0x83) //Master is requesting data |
89 |
if(state > 0x83) //Master is requesting data |
82 |
{ |
90 |
{ |
83 |
i2c_write(0x00); // There is nothing to prepare, so zero |
91 |
i2c_write(0x00); // There is nothing to prepare, so zero |
Line 123... |
Line 131... |
123 |
void TIMER1_isr(void) |
131 |
void TIMER1_isr(void) |
124 |
{ |
132 |
{ |
125 |
of++; |
133 |
of++; |
126 |
} |
134 |
} |
127 |
|
135 |
|
128 |
|
- |
|
129 |
void main() |
136 |
void main() |
130 |
{ |
137 |
{ |
131 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
138 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
132 |
setup_adc(ADC_OFF); |
139 |
setup_adc(ADC_OFF); |
133 |
// setup_spi(SPI_SS_DISABLED); //must not be set if I2C are in use! |
140 |
// setup_spi(SPI_SS_DISABLED); //must not be set if I2C are in use! |
Line 141... |
Line 148... |
141 |
restart_wdt(); |
148 |
restart_wdt(); |
142 |
delay_ms(1000); |
149 |
delay_ms(1000); |
143 |
restart_wdt(); |
150 |
restart_wdt(); |
144 |
|
151 |
|
145 |
// setup GPS |
152 |
// setup GPS |
146 |
{ |
- |
|
147 |
int n; |
153 |
setup_GPS(); |
148 |
for (n=0;n<40;n++) putc(cmd[n]); |
- |
|
149 |
} |
- |
|
150 |
|
154 |
|
151 |
ext_int_edge( L_TO_H ); // set 1PPS active edge |
155 |
ext_int_edge( L_TO_H ); // set 1PPS active edge |
152 |
enable_interrupts(INT_TIMER1); |
156 |
enable_interrupts(INT_TIMER1); |
153 |
enable_interrupts(INT_EXT); |
157 |
enable_interrupts(INT_EXT); |
154 |
enable_interrupts(INT_SSP); |
158 |
enable_interrupts(INT_SSP); |