55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
|
/*
|
||
|
Copyright 2022, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||
|
|
||
|
This file is part of Savanni's AVR library.
|
||
|
|
||
|
Lumeto is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||
|
|
||
|
Lumeto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
#ifndef __RFM_H__
|
||
|
#define __RFM_H__
|
||
|
|
||
|
#include <base.h>
|
||
|
#include <spi.h>
|
||
|
|
||
|
typedef struct RFM {
|
||
|
spi_t spi;
|
||
|
gpio_t irq;
|
||
|
gpio_t reset;
|
||
|
} rfm_t;
|
||
|
|
||
|
typedef enum packet_format {
|
||
|
unlimited,
|
||
|
fixed,
|
||
|
variable,
|
||
|
} packet_format_e;
|
||
|
|
||
|
typedef enum MODE {
|
||
|
sleep,
|
||
|
standby,
|
||
|
fs,
|
||
|
tx,
|
||
|
rx
|
||
|
} mode_e;
|
||
|
|
||
|
void rfm_initialize(rfm_t *rfm);
|
||
|
void rfm_packet_format(rfm_t *rfm, packet_format_e format, size_t length);
|
||
|
|
||
|
void rfm_send_data(rfm_t *rfm, uint8_t *data, size_t length);
|
||
|
void rfm_receive_data(rfm_t *rfm, uint8_t *data, size_t length);
|
||
|
|
||
|
uint8_t rfm_mode(rfm_t *rfm);
|
||
|
uint8_t rfm_status(rfm_t *rfm);
|
||
|
uint8_t rfm_temperature(rfm_t *rfm);
|
||
|
uint32_t rfm_frequency(rfm_t *rfm);
|
||
|
|
||
|
void rfm_listen(rfm_t *rfm);
|
||
|
uint8_t rfm_set_mode(rfm_t *rfm, mode_e mode);
|
||
|
uint8_t rfm_irq_1(rfm_t *rfm);
|
||
|
|
||
|
#endif
|