You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.6 KiB

6 years ago
#include <util/delay.h>
#include <avr/io.h>
#include <stdio.h>
#include <stdarg.h>
#include <util/setbaud.h>
#include <Arduino.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 7
#define CSN_PIN 8
5 years ago
#define LED PORTD2
5 years ago
#define PULL PORTD3
#define ENABLE PORTD5
#define DIRECTION PORTD6
6 years ago
void uart_init() {
// Upper and lower bytes of the calculated prescaler value for baud.
UBRR0H = UBRRH_VALUE;
UBRR0L = UBRRL_VALUE;
// Configure data frame size to 8-bits.
UCSR0C = _BV(UCSZ01) | _BV(UCSZ00);
// Configure to enable transmitter.
UCSR0B = _BV(TXEN0);
}
void uart_putchar(char c) {
// Wait until the register to write to is free.
loop_until_bit_is_set(UCSR0A, UDRE0);
// Write the byte to the register.
UDR0 = c;
}
void uart_putstr(char *data) {
// Loop until end of string writing char by char.
while(*data){
uart_putchar(*data++);
}
}
const char thisSlaveAddress[5] = {'R','x','A','A','A'};
5 years ago
6 years ago
int main(void) {
digitalWrite(10, 10);
RF24 value(CE_PIN, CSN_PIN);
6 years ago
uart_init();
DDRC &= ~(1<<0); // Input
PORTC |= (1<<0); // Enable Internal Pull Up (Setting it to HIGH)
5 years ago
// DDRD |= (1 << ENABLE);
DDRD = DDRD | 0xFC;
PORTD |= _BV(ENABLE);
PORTD |= _BV(DIRECTION);
6 years ago
for(;;){
5 years ago
// uart_putstr("hello\n");
_delay_ms(400);
PORTD |= _BV(PULL);
_delay_ms(400);
PORTD &= ~_BV(PULL);
6 years ago
5 years ago
uint8_t port_value = 2;
// port_value = PINC & (1 << 0);
uart_putchar((char)port_value);
5 years ago
// uart_putchar((char)'\n');
6 years ago
}
}