mirror of
https://github.com/eddyem/stm32samples.git
synced 2026-01-31 20:35:06 +03:00
Seems like ALL OK
This commit is contained in:
parent
52447eef63
commit
5a9f360a70
@ -155,7 +155,8 @@ void GPS_parse_answer(uint8_t *buf){
|
||||
*ptr++ = 0;
|
||||
if(*ptr == 'A'){
|
||||
GPS_status = GPS_VALID;
|
||||
set_time(buf);
|
||||
}else
|
||||
}else{
|
||||
GPS_status = GPS_NOT_VALID;
|
||||
}
|
||||
set_time(buf);
|
||||
}
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
BINARY = timelapse
|
||||
BOOTPORT ?= /dev/ttyUSB0
|
||||
BOOTSPEED ?= 115200
|
||||
# change this linking script depending on particular MCU model,
|
||||
# for example, if you have STM32F103VBT6, you should write:
|
||||
# change this linking script depending on particular MCU model
|
||||
LDSCRIPT = ld/stm32f103x8.ld
|
||||
LIBNAME = opencm3_stm32f1
|
||||
# add -DULTRASONIC to compile with ultrasonic distance-meter support
|
||||
|
||||
@ -35,15 +35,15 @@
|
||||
void GPIO_init();
|
||||
void SysTick_init();
|
||||
|
||||
// yellow LEDs: PA11, PA12
|
||||
// yellow LEDs: PA11, PA12; Y1- - trigr, Y2 - PPS
|
||||
#define LEDS_Y_PORT GPIOA
|
||||
#define LEDS_Y1_PIN GPIO13
|
||||
#define LEDS_Y2_PIN GPIO15
|
||||
// green LEDs: PB7, PB8
|
||||
// green LEDs: PB7, PB8; G1 - GPS rdy
|
||||
#define LEDS_G_PORT GPIOB
|
||||
#define LEDS_G1_PIN GPIO7
|
||||
#define LEDS_G2_PIN GPIO8
|
||||
// red LEDs: PB6, PB5
|
||||
// red LEDs: PB6, PB5; R2 - power
|
||||
#define LEDS_R_PORT GPIOB
|
||||
#define LEDS_R1_PIN GPIO6
|
||||
#define LEDS_R2_PIN GPIO5
|
||||
|
||||
@ -65,7 +65,8 @@ void time_increment(){
|
||||
}
|
||||
|
||||
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;
|
||||
rcc_clock_setup_in_hse_8mhz_out_72mhz();
|
||||
// init systick (1ms)
|
||||
@ -107,6 +108,8 @@ int main(void){
|
||||
iwdg_set_period_ms(50); // set watchdog timeout to 50ms
|
||||
iwdg_start();
|
||||
while(1){
|
||||
if(Timer == 500) // turn off PPS LED after 500ms
|
||||
gpio_set(LEDS_Y_PORT, LEDS_Y2_PIN);
|
||||
poll_usbkeybrd();
|
||||
if(usbkbrdtm != msctr){ // process USB not frequently than once per 1ms
|
||||
process_usbkbrd();
|
||||
@ -117,7 +120,7 @@ int main(void){
|
||||
#endif
|
||||
poll_ADC();
|
||||
if((string = check_UART2())){
|
||||
lastGPSans = string;
|
||||
memcpy(lastGPSans, string, UART_BUF_DATA_SIZE);
|
||||
GPS_parse_answer(string);
|
||||
}
|
||||
/*
|
||||
@ -149,7 +152,7 @@ if(msctr - trigrtm > 3000){
|
||||
istriggered = 1;
|
||||
P("Button time: ");
|
||||
print_time(&trigger_time, trigger_ms);
|
||||
if(lastGPSans){
|
||||
if(*lastGPSans){
|
||||
P("GPS last message: ");
|
||||
send_msg((char*)lastGPSans);
|
||||
newline();
|
||||
@ -221,11 +224,12 @@ if(msctr - trigrtm > 3000){
|
||||
}
|
||||
// check GPS status to turn on/off GPS LED
|
||||
if(current_time.H < 24){ // timer OK
|
||||
if(GPS_status != GPS_VALID || need_sync)
|
||||
if((GPS_status != GPS_VALID) || need_sync){
|
||||
GPSLEDblink = 1;
|
||||
else if(GPSLEDblink){
|
||||
}else{
|
||||
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(msctr - GPSstatus_tm > 500 || msctr < GPSstatus_tm){
|
||||
@ -268,6 +272,7 @@ void exti4_isr(){
|
||||
uint32_t t = 0, ticks;
|
||||
static uint32_t ticksavr = 0, N = 0;
|
||||
if(EXTI_PR & EXTI4){
|
||||
gpio_clear(LEDS_Y_PORT, LEDS_Y2_PIN);
|
||||
// correct
|
||||
systick_val = STK_CVR;
|
||||
STK_CVR = RVR0;
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user