From: Bernhard Tittelbach Date: Sat, 24 Apr 2010 15:57:08 +0000 (+0000) Subject: eliminate send_frame racecondition X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=9bd73ef41f4bde3ac3a234095a14adf3c6aa500d;p=svn42.git eliminate send_frame racecondition --- diff --git a/rf433ctl/rf433ctl.pde b/rf433ctl/rf433ctl.pde index 2191f4d..cc6e917 100644 --- a/rf433ctl/rf433ctl.pde +++ b/rf433ctl/rf433ctl.pde @@ -179,8 +179,8 @@ ISR(TIMER1_COMPA_vect) word_cnt++; if(word_cnt < FRAME_LEN) init_word(current_word); - - frame_finished = 1; + else + frame_finished = 2; } //***********// @@ -188,15 +188,25 @@ ISR(TIMER1_COMPA_vect) void send_frame(const word_t w) { + if (frame_finished == 0) + for(;;) + if (frame_finished) + { + delay(10); + break; + } word_cnt = 0; frame_finished = 0; - init_word(w); - - for(;;) - if(frame_finished) - break; + init_word(w); +} - Serial.println("Ok"); +void check_frame_done() +{ + if (frame_finished==2) + { + Serial.println("Ok"); + frame_finished=1; + } } //********************************************************************// @@ -372,6 +382,7 @@ void loop() updateLightLevel(PHOTO_ANALOGPIN); calculate_led_level(BLUELED_PWM_PIN); + check_frame_done(); if(Serial.available()) { char command = Serial.read();