2021-03-31 20:52:26 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cc1101_regs.h"
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2022-01-05 19:10:18 +03:00
|
|
|
#include <furi_hal_spi.h>
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Low level API */
|
|
|
|
|
|
|
|
/** Strobe command to the device
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
* @param strobe - command to execute
|
|
|
|
*
|
|
|
|
* @return device status
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
CC1101Status cc1101_strobe(FuriHalSpiBusHandle* handle, uint8_t strobe);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Write device register
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
* @param reg - register
|
|
|
|
* @param data - data to write
|
|
|
|
*
|
|
|
|
* @return device status
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
CC1101Status cc1101_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Read device register
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
* @param reg - register
|
|
|
|
* @param[out] data - pointer to data
|
|
|
|
*
|
|
|
|
* @return device status
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
CC1101Status cc1101_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/* High level API */
|
|
|
|
|
|
|
|
/** Reset
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
void cc1101_reset(FuriHalSpiBusHandle* handle);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
2021-06-08 12:51:16 +03:00
|
|
|
/** Get status
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
*
|
|
|
|
* @return CC1101Status structure
|
2021-06-08 12:51:16 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
CC1101Status cc1101_get_status(FuriHalSpiBusHandle* handle);
|
2021-06-08 12:51:16 +03:00
|
|
|
|
2021-03-31 20:52:26 +03:00
|
|
|
/** Enable shutdown mode
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
void cc1101_shutdown(FuriHalSpiBusHandle* handle);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Get Partnumber
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
*
|
|
|
|
* @return part number id
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
uint8_t cc1101_get_partnumber(FuriHalSpiBusHandle* handle);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Get Version
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
*
|
|
|
|
* @return version
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
uint8_t cc1101_get_version(FuriHalSpiBusHandle* handle);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Get raw RSSI value
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
*
|
|
|
|
* @return rssi value
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
uint8_t cc1101_get_rssi(FuriHalSpiBusHandle* handle);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Calibrate oscillator
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
void cc1101_calibrate(FuriHalSpiBusHandle* handle);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Switch to idle
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
void cc1101_switch_to_idle(FuriHalSpiBusHandle* handle);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Switch to RX
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
void cc1101_switch_to_rx(FuriHalSpiBusHandle* handle);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Switch to TX
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
void cc1101_switch_to_tx(FuriHalSpiBusHandle* handle);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Flush RX FIFO
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
void cc1101_flush_rx(FuriHalSpiBusHandle* handle);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Flush TX FIFO
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
void cc1101_flush_tx(FuriHalSpiBusHandle* handle);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Set Frequency
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
* @param value - frequency in herz
|
|
|
|
*
|
|
|
|
* @return real frequency that were synthesized
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
uint32_t cc1101_set_frequency(FuriHalSpiBusHandle* handle, uint32_t value);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
2021-07-18 21:09:00 +03:00
|
|
|
/** Set Intermediate Frequency
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
* @param value - frequency in herz
|
|
|
|
*
|
|
|
|
* @return real inermediate frequency that were synthesized
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
uint32_t cc1101_set_intermediate_frequency(FuriHalSpiBusHandle* handle, uint32_t value);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Set Power Amplifier level table, ramp
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
* @param value - array of power level values
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
void cc1101_set_pa_table(FuriHalSpiBusHandle* handle, const uint8_t value[8]);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Write FIFO
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
* @param data pointer to byte array
|
|
|
|
* @param size write bytes count
|
|
|
|
*
|
|
|
|
* @return size, written bytes count
|
2021-03-31 20:52:26 +03:00
|
|
|
*/
|
2021-11-30 15:09:43 +03:00
|
|
|
uint8_t cc1101_write_fifo(FuriHalSpiBusHandle* handle, const uint8_t* data, uint8_t size);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
/** Read FIFO
|
2021-11-30 15:09:43 +03:00
|
|
|
*
|
|
|
|
* @param handle - pointer to FuriHalSpiHandle
|
|
|
|
* @param data pointer to byte array
|
|
|
|
* @param size bytes to read from fifo
|
|
|
|
*
|
|
|
|
* @return size, read bytes count
|
|
|
|
*/
|
|
|
|
uint8_t cc1101_read_fifo(FuriHalSpiBusHandle* handle, uint8_t* data, uint8_t* size);
|
2021-03-31 20:52:26 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2022-05-06 16:37:10 +03:00
|
|
|
#endif
|