-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.c
95 lines (71 loc) · 2.76 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* 433 MHz key fob jammer based on ATTINY13A and FS1000A RF transmitting module
* PIN B2 of ATTINY13A is connected to DATA IN of FS1000A transmitter board
* both ATTINY13 and FS1000A are connected to 5V power supply
* internal clock 9.6MHz with division by 8 = 1.2MHz effective clock
*
*/
#include <stdint.h>
#include <avr/io.h>
#include <util/delay.h>
#define FS1000A_DATA_HIGH() (PORTB |= _BV(FS1000A_DATA_PIN))
#define FS1000A_DATA_LOW() (PORTB &= ~_BV(FS1000A_DATA_PIN))
#define FS1000A_DATA_OUTPUT() (DDRB |= _BV(FS1000A_DATA_PIN))
// Main Settings
#define FS1000A_DATA_PIN PB2
int main(void)
{
uint8_t widthsize;
uint8_t sequence;
uint8_t duration;
// SET OUTPUT PIN TO STEER FS1000A DATA IN
FS1000A_DATA_OUTPUT();
FS1000A_DATA_LOW();
/* neverending loop */
while (1) {
widthsize = 0;
sequence = 0;
duration = 0;
// generating SQUARE WAVE for FS1000A DATA INPUT
// we send 50 sequences of 3 pulses different width ( from 50us to 2.5 ms )
// to generate enough distortion on 433 MHz frequency
// and get widest possible bandwith covered on spectrum
for(sequence=1; sequence<50; sequence++)
{
// only 10 pulses for each width
for(duration=1; duration<=3; duration++)
{
FS1000A_DATA_HIGH(); // bring DATA PIN up
// starting from 50usec width Pulses
for(widthsize=1; widthsize<=(1+sequence); widthsize++)
{
// Generated by delay loop calculator
// at http://www.bretmulvey.com/avrdelay.html
//
// Delay 60 cycles
// 50us at 1.2 MHz
asm volatile (
" ldi r18, 20" "\n"
"1: dec r18" "\n"
" brne 1b" "\n"
);
}; // end of widthsize for loop
FS1000A_DATA_LOW(); // drag DATA PIN down
// starting from 50usec Pulses
for(widthsize=1; widthsize<=(1+sequence); widthsize++)
{
// Generated by delay loop calculator
// at http://www.bretmulvey.com/avrdelay.html
//
// Delay 60 cycles
// 50us at 1.2 MHz
asm volatile (
" ldi r18, 20" "\n"
"1: dec r18" "\n"
" brne 1b" "\n"
);
}; // end of WIDTHSIZE variable for loop
}; // end of DURATION loop
}; // end of SEQUENCE variable loop
}; // neverending loop
}; // end of MAIN