X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=rf433rcv%2Fteensy%2Fexample.c;h=063e26ad9eb3e0cfc5f7972ef031280f963ea72a;hb=f68b759341acb46b8011529d6ee92d5c179edf97;hp=ebf77e2cdf86f94047b85a58e557a1d736c6e36a;hpb=02293cb00639b97ca422619ee15f5981a5b3ffd0;p=svn42.git diff --git a/rf433rcv/teensy/example.c b/rf433rcv/teensy/example.c index ebf77e2..063e26a 100644 --- a/rf433rcv/teensy/example.c +++ b/rf433rcv/teensy/example.c @@ -28,18 +28,18 @@ #include "usb_rawhid.h" #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) -#define RF_SEND_BUFFER_LEN_MAX 128 +#define RF_SEND_BUFFER_LEN_MAX 502 volatile uint16_t output_count=0; volatile uint8_t active_buffer=0; volatile uint16_t send_buffer=0; volatile uint8_t capture=0; -volatile uint8_t rf_send=0; //count of bits in rf_send_buffer that should be sent -volatile uint8_t rf_send_reload=0; //count of bits in rf_send_buffer that should be sent -volatile uint8_t rf_send_reload_count=0; // number of repetitions (times rf_send gets reloaded; +volatile uint16_t rf_send_buf_pos=0; //count of bits in rf_send_buffer that should be sent +volatile uint16_t rf_send_buf_len=0; //count of bits in rf_send_buffer that should be sent +volatile uint8_t rf_send_count=0; // number of repetitions (times rf_send gets reloaded; uint8_t read_buffer[64]; // buffer for reading usb signals uint8_t write_buffer[2][64]; // buffer for writing usb signals uint8_t rf_send_buffer[RF_SEND_BUFFER_LEN_MAX]; // buffer for sending rf433 signals -uint8_t rf_send_buffer_len=0; +uint16_t rf_send_buf_offset=0; void reset() @@ -85,10 +85,10 @@ int main(void) DDRF|=3; PORTF&=~1; // Configure timer 0 to generate a timer overflow interrupt every - // 200*8 clock cycles, 100us + // 100*8 clock cycles, 50us TCCR0A = 1<2) - rf_send_reload=rf_send_buffer_len*8-read_buffer[2]; // substract bit offset - else - rf_send_reload=rf_send_buffer_len*8; - rf_send_reload_count=read_buffer[1]; + rf_send_buf_pos=0; + rf_send_count=read_buffer[1]+1; } } if (send_buffer) { send_buffer=0; - usb_rawhid_send(write_buffer[active_buffer?0:1], 45); + usb_rawhid_send(write_buffer[active_buffer?0:1], 23); } } } @@ -147,20 +148,21 @@ int main(void) ISR(TIMER0_COMPA_vect) { PORTF^=2; - if (rf_send) + if (rf_send_count && rf_send_buf_pos>=1; + rf_send_buf_pos++; + } else if (rf_send_count) { + rf_send_buf_pos=0; + rf_send_count--; } else { - PORTF&=~1; + PORTF&=~1; if (capture) { write_buffer[active_buffer][output_count/8]<<=1; write_buffer[active_buffer][output_count++/8]|=PINB&1;