49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <avr/io.h>
|
|
#include "mrf24j.h"
|
|
|
|
|
|
#if defined __AVR_ATmega328P__
|
|
#define SPI_DDR DDRB
|
|
#define SPI_PORT PORTB
|
|
#define SPI_SCK PB5
|
|
#define SPI_MISO PB4
|
|
#define SPI_MOSI PB3
|
|
#define SPI_CS PB2
|
|
#define RESET_DDR DDRB
|
|
#define RESET_PORT PORTB
|
|
#define RESET PB0
|
|
#define WAKE_PORT PORTB
|
|
#define WAKE_DDR DDRB
|
|
#define WAKE_PIN PB1
|
|
#define INTERRUPT ISR(INT0_vect)
|
|
#elif defined __AVR_ATmega32__ || defined __AVR_ATmega16__
|
|
#define SPI_PORT PORTB
|
|
#define SPI_DDR DDRB
|
|
#define SPI_SCK PB7
|
|
#define SPI_MOSI PB5
|
|
#define SPI_CS PB4
|
|
#define RESET_DDR DDRB
|
|
#define RESET_PORT PORTB
|
|
#define RESET PB0
|
|
#define WAKE_PORT PORTB
|
|
#define WAKE_DDR DDRB
|
|
#define WAKE_PIN PB1
|
|
#define INTERRUPT ISR(INT2_vect)
|
|
#elif defined RASPBERRYPI
|
|
|
|
#endif
|
|
|
|
namespace driver
|
|
{
|
|
void init(Mrf24j *mrf);
|
|
uint8_t transfer(uint8_t data);
|
|
|
|
inline void cs_low() {SPI_PORT &= ~(1<<SPI_CS);}
|
|
|
|
inline void cs_high() {SPI_PORT |= (1<<SPI_CS);}
|
|
void wake();
|
|
void reset();
|
|
} // namespace spi
|