Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MASTER
- ===========================================
- #define F_CPU 16000000UL
- #include "master.h"
- #include <avr/io.h>
- #include <avr/pgmspace.h>
- #include <avr/interrupt.h>
- #include <stdio.h>
- #include <util/delay.h>
- #include "nRF905/nRF905.h"
- #define RXADDR {0x58, 0x6F, 0x2E, 0x10} // Address of this device (4 bytes)
- #define TXADDR {0xFE, 0x4C, 0xA6, 0xE5} // Address of device to send to (4 bytes)
- int main(void)
- {
- // LED indicator
- //config led
- DDRC |= _BV(DDC5);
- // Start up
- nRF905_init();
- // Set address of this device
- uint8_t addrRx[] = RXADDR;
- nRF905_setRXAddress(addrRx);
- // Set address of device to send to
- uint8_t addr[] = TXADDR;
- nRF905_setTXAddress(addr);
- // Interrupts on
- sei();
- // Make buffer for data
- char mesaj[NRF905_MAX_PAYLOAD] = "test test";
- //on
- PORTC |= _BV(PORTC5);
- while(1)
- {
- nRF905_setData(mesaj, sizeof(mesaj));
- while(!nRF905_send());
- }
- }
- ==========================================================================
- SLAVE
- ==========================================================================
- #define F_CPU 16000000UL
- #include "slave.h"
- #include <avr/io.h>
- #include <avr/pgmspace.h>
- #include <avr/interrupt.h>
- #include <stdio.h>
- #include <util/delay.h>
- #include "nRF905/nRF905.h"
- #include "UART.h"
- #define RXADDR {0xFE, 0x4C, 0xA6, 0xE5} // Address of this device (4 bytes)
- #define TXADDR {0x58, 0x6F, 0x2E, 0x10} // Address of device to send to (4 bytes)
- int main(void)
- {
- // LED indicator
- //config led
- DDRC |= _BV(DDC5);
- UART_init();
- nRF905_init();
- // Set address of this device
- uint8_t addrRx[] = RXADDR;
- nRF905_setRXAddress(addrRx);
- // Interrupts on
- sei();
- // Put into receive mode
- nRF905_receive();
- uint8_t mesaj[NRF905_MAX_PAYLOAD];
- UART_sendstring("start\r" , '\r');
- //on
- PORTC |= _BV(PORTC5);
- // Wait for data
- while(!nRF905_getData(mesaj, sizeof(mesaj)));
- UART_sendstring("ok\r" , '\r');
- //off
- PORTC &= ~_BV(PORTC5);
- UART_sendstring(mesaj , '\r');
- }
- ===================================================
- all UART stuff is a library that is fully working
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement