Update nrf24 pins

This commit is contained in:
Rihards Skuja 2018-01-03 20:27:35 +02:00
parent 4f2b6d242a
commit 98e9ccf3dd
No known key found for this signature in database
GPG Key ID: 53FA13A3F7F8571B

View File

@ -12,54 +12,63 @@
#include <avr/io.h>
#include "common.h"
#define REG DDRB
#define PORT PORTB
#define PIN PINB
#define PIN_CE PB0
#define PIN_CSN PB1
#define PIN_SCK PB5
#define PIN_MOSI PB3
#define PIN_MISO PB4
/* ------------------------------------------------------------------------- */
void nrf24_setupPins()
void nrf24_setupPins(void)
{
SET(DDRC, 0); // CE output
SET(DDRC, 1); // CSN output
SET(DDRC, 2); // SCK output
SET(DDRC, 3); // MOSI output
CLR(DDRC, 4); // MISO input
SET(REG, PIN_CE);
SET(REG, PIN_CSN);
SET(REG, PIN_SCK);
SET(REG, PIN_MOSI);
CLR(REG, PIN_MISO);
}
/* ------------------------------------------------------------------------- */
void nrf24_ce_digitalWrite(uint8_t state)
{
if (state) {
SET(PORTC, 0);
SET(PORT, PIN_CE);
} else {
CLR(PORTC, 0);
CLR(PORT, PIN_CE);
}
}
/* ------------------------------------------------------------------------- */
void nrf24_csn_digitalWrite(uint8_t state)
{
if (state) {
SET(PORTC, 1);
SET(PORT, PIN_CSN);
} else {
CLR(PORTC, 1);
CLR(PORT, PIN_CSN);
}
}
/* ------------------------------------------------------------------------- */
void nrf24_sck_digitalWrite(uint8_t state)
{
if (state) {
SET(PORTC, 2);
SET(PORT, PIN_SCK);
} else {
CLR(PORTC, 2);
CLR(PORT, PIN_SCK);
}
}
/* ------------------------------------------------------------------------- */
void nrf24_mosi_digitalWrite(uint8_t state)
{
if (state) {
SET(PORTC, 3);
SET(PORT, PIN_MOSI);
} else {
CLR(PORTC, 3);
CLR(PORT, PIN_MOSI);
}
}
/* ------------------------------------------------------------------------- */
uint8_t nrf24_miso_digitalRead()
uint8_t nrf24_miso_digitalRead(void)
{
return CHK(PINC, 4);
return CHK(PIN, PIN_MISO);
}
/* ------------------------------------------------------------------------- */