unleashed-firmware/lib/drivers/cc1101.h

144 lines
3.9 KiB
C
Raw Normal View History

#pragma once
#include "cc1101_regs.h"
#include <stdbool.h>
#include <stdint.h>
2021-08-08 18:03:25 +00:00
#include <furi-hal-spi.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Low level API */
/** Strobe command to the device
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
* @param strobe - command to execute
* @return device status
*/
2021-08-08 18:03:25 +00:00
CC1101Status cc1101_strobe(const FuriHalSpiDevice* device, uint8_t strobe);
/** Write device register
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
* @param reg - register
* @param data - data to write
* @return device status
*/
2021-08-08 18:03:25 +00:00
CC1101Status cc1101_write_reg(const FuriHalSpiDevice* device, uint8_t reg, uint8_t data);
/** Read device register
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
* @param reg - register
* @param[out] data - pointer to data
* @return device status
*/
2021-08-08 18:03:25 +00:00
CC1101Status cc1101_read_reg(const FuriHalSpiDevice* device, uint8_t reg, uint8_t* data);
/* High level API */
/** Reset
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
void cc1101_reset(const FuriHalSpiDevice* device);
/** Get status
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
CC1101Status cc1101_get_status(const FuriHalSpiDevice* device);
/** Enable shutdown mode
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
void cc1101_shutdown(const FuriHalSpiDevice* device);
/** Get Partnumber
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
uint8_t cc1101_get_partnumber(const FuriHalSpiDevice* device);
/** Get Version
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
uint8_t cc1101_get_version(const FuriHalSpiDevice* device);
/** Get raw RSSI value
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
uint8_t cc1101_get_rssi(const FuriHalSpiDevice* device);
/** Calibrate oscillator
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
void cc1101_calibrate(const FuriHalSpiDevice* device);
/** Switch to idle
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
void cc1101_switch_to_idle(const FuriHalSpiDevice* device);
/** Switch to RX
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
void cc1101_switch_to_rx(const FuriHalSpiDevice* device);
/** Switch to TX
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
void cc1101_switch_to_tx(const FuriHalSpiDevice* device);
/** Flush RX FIFO
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
void cc1101_flush_rx(const FuriHalSpiDevice* device);
/** Flush TX FIFO
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
*/
2021-08-08 18:03:25 +00:00
void cc1101_flush_tx(const FuriHalSpiDevice* device);
/** Set Frequency
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
* @param value - frequency in herz
* @return real frequency that were synthesized
*/
2021-08-08 18:03:25 +00:00
uint32_t cc1101_set_frequency(const FuriHalSpiDevice* device, uint32_t value);
/** Set Intermediate Frequency
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
* @param value - frequency in herz
* @return real inermediate frequency that were synthesized
*/
2021-08-08 18:03:25 +00:00
uint32_t cc1101_set_intermediate_frequency(const FuriHalSpiDevice* device, uint32_t value);
/** Set Power Amplifier level table, ramp
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
* @param value - array of power level values
*/
2021-08-08 18:03:25 +00:00
void cc1101_set_pa_table(const FuriHalSpiDevice* device, const uint8_t value[8]);
/** Set Power Amplifier level table, ramp
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
* @param value - array of power level values
*/
2021-08-08 18:03:25 +00:00
void cc1101_set_pa_table(const FuriHalSpiDevice* device, const uint8_t value[8]);
/** Write FIFO
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
* @param data, pointer to byte array
* @param size, write bytes count
* @return size, written bytes count
*/
2021-08-08 18:03:25 +00:00
uint8_t cc1101_write_fifo(const FuriHalSpiDevice* device, const uint8_t* data, uint8_t size);
/** Read FIFO
2021-08-08 18:03:25 +00:00
* @param device - pointer to FuriHalSpiDevice
* @param data, pointer to byte array
* @param size, bytes to read from fifo
* @return size, read bytes count
*/
2021-08-08 18:03:25 +00:00
uint8_t cc1101_read_fifo(const FuriHalSpiDevice* device, uint8_t* data, uint8_t* size);
#ifdef __cplusplus
}
#endif