Seems like ALL OK

This commit is contained in:
eddyem 2015-09-16 18:21:03 +03:00
parent 52447eef63
commit 5a9f360a70
5 changed files with 18 additions and 13 deletions

View File

@ -155,7 +155,8 @@ void GPS_parse_answer(uint8_t *buf){
*ptr++ = 0; *ptr++ = 0;
if(*ptr == 'A'){ if(*ptr == 'A'){
GPS_status = GPS_VALID; GPS_status = GPS_VALID;
set_time(buf); }else{
}else
GPS_status = GPS_NOT_VALID; GPS_status = GPS_NOT_VALID;
}
set_time(buf);
} }

View File

@ -1,8 +1,7 @@
BINARY = timelapse BINARY = timelapse
BOOTPORT ?= /dev/ttyUSB0 BOOTPORT ?= /dev/ttyUSB0
BOOTSPEED ?= 115200 BOOTSPEED ?= 115200
# change this linking script depending on particular MCU model, # change this linking script depending on particular MCU model
# for example, if you have STM32F103VBT6, you should write:
LDSCRIPT = ld/stm32f103x8.ld LDSCRIPT = ld/stm32f103x8.ld
LIBNAME = opencm3_stm32f1 LIBNAME = opencm3_stm32f1
# add -DULTRASONIC to compile with ultrasonic distance-meter support # add -DULTRASONIC to compile with ultrasonic distance-meter support

View File

@ -35,15 +35,15 @@
void GPIO_init(); void GPIO_init();
void SysTick_init(); void SysTick_init();
// yellow LEDs: PA11, PA12 // yellow LEDs: PA11, PA12; Y1- - trigr, Y2 - PPS
#define LEDS_Y_PORT GPIOA #define LEDS_Y_PORT GPIOA
#define LEDS_Y1_PIN GPIO13 #define LEDS_Y1_PIN GPIO13
#define LEDS_Y2_PIN GPIO15 #define LEDS_Y2_PIN GPIO15
// green LEDs: PB7, PB8 // green LEDs: PB7, PB8; G1 - GPS rdy
#define LEDS_G_PORT GPIOB #define LEDS_G_PORT GPIOB
#define LEDS_G1_PIN GPIO7 #define LEDS_G1_PIN GPIO7
#define LEDS_G2_PIN GPIO8 #define LEDS_G2_PIN GPIO8
// red LEDs: PB6, PB5 // red LEDs: PB6, PB5; R2 - power
#define LEDS_R_PORT GPIOB #define LEDS_R_PORT GPIOB
#define LEDS_R1_PIN GPIO6 #define LEDS_R1_PIN GPIO6
#define LEDS_R2_PIN GPIO5 #define LEDS_R2_PIN GPIO5

View File

@ -65,7 +65,8 @@ void time_increment(){
} }
int main(void){ int main(void){
uint8_t *string, *lastGPSans = NULL; // string from UART2 & pointer to last full GPS answer uint8_t *string; // string from UART2 & pointer to last full GPS answer
uint8_t lastGPSans[UART_BUF_DATA_SIZE] = {0};
int i; int i;
rcc_clock_setup_in_hse_8mhz_out_72mhz(); rcc_clock_setup_in_hse_8mhz_out_72mhz();
// init systick (1ms) // init systick (1ms)
@ -107,6 +108,8 @@ int main(void){
iwdg_set_period_ms(50); // set watchdog timeout to 50ms iwdg_set_period_ms(50); // set watchdog timeout to 50ms
iwdg_start(); iwdg_start();
while(1){ while(1){
if(Timer == 500) // turn off PPS LED after 500ms
gpio_set(LEDS_Y_PORT, LEDS_Y2_PIN);
poll_usbkeybrd(); poll_usbkeybrd();
if(usbkbrdtm != msctr){ // process USB not frequently than once per 1ms if(usbkbrdtm != msctr){ // process USB not frequently than once per 1ms
process_usbkbrd(); process_usbkbrd();
@ -117,7 +120,7 @@ int main(void){
#endif #endif
poll_ADC(); poll_ADC();
if((string = check_UART2())){ if((string = check_UART2())){
lastGPSans = string; memcpy(lastGPSans, string, UART_BUF_DATA_SIZE);
GPS_parse_answer(string); GPS_parse_answer(string);
} }
/* /*
@ -149,7 +152,7 @@ if(msctr - trigrtm > 3000){
istriggered = 1; istriggered = 1;
P("Button time: "); P("Button time: ");
print_time(&trigger_time, trigger_ms); print_time(&trigger_time, trigger_ms);
if(lastGPSans){ if(*lastGPSans){
P("GPS last message: "); P("GPS last message: ");
send_msg((char*)lastGPSans); send_msg((char*)lastGPSans);
newline(); newline();
@ -221,11 +224,12 @@ if(msctr - trigrtm > 3000){
} }
// check GPS status to turn on/off GPS LED // check GPS status to turn on/off GPS LED
if(current_time.H < 24){ // timer OK if(current_time.H < 24){ // timer OK
if(GPS_status != GPS_VALID || need_sync) if((GPS_status != GPS_VALID) || need_sync){
GPSLEDblink = 1; GPSLEDblink = 1;
else if(GPSLEDblink){ }else{
GPSLEDblink = 0; GPSLEDblink = 0;
gpio_clear(LEDS_G_PORT, LEDS_G1_PIN); // turn ON G1 LED if((GPIO_ODR(LEDS_G_PORT) & LEDS_G1_PIN) == 0)
gpio_clear(LEDS_G_PORT, LEDS_G1_PIN); // turn ON G1 LED
} }
if(GPSLEDblink){ if(GPSLEDblink){
if(msctr - GPSstatus_tm > 500 || msctr < GPSstatus_tm){ if(msctr - GPSstatus_tm > 500 || msctr < GPSstatus_tm){
@ -268,6 +272,7 @@ void exti4_isr(){
uint32_t t = 0, ticks; uint32_t t = 0, ticks;
static uint32_t ticksavr = 0, N = 0; static uint32_t ticksavr = 0, N = 0;
if(EXTI_PR & EXTI4){ if(EXTI_PR & EXTI4){
gpio_clear(LEDS_Y_PORT, LEDS_Y2_PIN);
// correct // correct
systick_val = STK_CVR; systick_val = STK_CVR;
STK_CVR = RVR0; STK_CVR = RVR0;

Binary file not shown.