-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
72 lines (57 loc) · 1.3 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
/* e-gadget.header
* main.c
*
* Created on: 2015-04-07
* Modyfied: 2015-04-07 19:45:16
* Author: Nefarious19
*
* Project name: "NRF24"
*
*
* MCU: ATmega32
* F_CPU: 16 000 000 Hz
*
* Flash: 2 992 bytes [ 9,1 % ]
* RAM: 189 bytes [ 9,2 % ]
* EEPROM: 0 bytes [ 0,0 % ]
*
*/
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdlib.h>
#include <string.h>
#include <avr/pgmspace.h>
//#include "usart.h"
#include "nRF24L01.h"
void moja_funkcja ( void * nRF_RX_buff , uint8_t len );
int main (void)
{
//led do migania
DDRB |= (1<<PB0);
PORTB &= ~(1<<PB0);
//inicjalizacja usarta
// init_USART(__UBRR);
//inicjalizacja nrfa
nRF_init();
register_nRF_RX_Event_Callback(moja_funkcja);
//odpalamy przerwanko
sei();
nRF_RX_Power_Up(); //odpalamy nRFA!
while(1)
{
nRF_RX_EVENT();
}
}
void moja_funkcja( void * nRF_RX_buff, uint8_t len )
{
// char buffer[10];
// usart_send_str( "ODEBRANO BAJTÓW: " );
// usart_send_str( itoa(len,buffer,10) );
// ENTER_NEW;
// usart_send_str( (char *) nRF_RX_buff );
// ENTER_NEW;
// nRF_SendDataToAir("DANE OK");
if (!strcmp_P( nRF_RX_buff , PSTR("ZAPAL_LED"))) PORTB |= (1<<PB0);
if (!strcmp_P( nRF_RX_buff , PSTR("ZGAS_LED"))) PORTB &= ~(1<<PB0);
}