flipperzero-firmware/lib/drivers/cc1101.h
あく 389ff92cc1
Naming and coding style convention, new linter tool. (#945)
* Makefile, Scripts: new linter
* About: remove ID from IC
* Firmware: remove double define for DIVC/DIVR
* Scripts: check folder names too. Docker: replace syntax check with make lint.
* Reformat Sources and Migrate to new file naming convention
* Docker: symlink clang-format-12 to clang-format
* Add coding style guide
2022-01-05 19:10:18 +03:00

180 lines
4.3 KiB
C

#pragma once
#include "cc1101_regs.h"
#include <stdbool.h>
#include <stdint.h>
#include <furi_hal_spi.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Low level API */
/** Strobe command to the device
*
* @param handle - pointer to FuriHalSpiHandle
* @param strobe - command to execute
*
* @return device status
*/
CC1101Status cc1101_strobe(FuriHalSpiBusHandle* handle, uint8_t strobe);
/** Write device register
*
* @param handle - pointer to FuriHalSpiHandle
* @param reg - register
* @param data - data to write
*
* @return device status
*/
CC1101Status cc1101_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data);
/** Read device register
*
* @param handle - pointer to FuriHalSpiHandle
* @param reg - register
* @param[out] data - pointer to data
*
* @return device status
*/
CC1101Status cc1101_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data);
/* High level API */
/** Reset
*
* @param handle - pointer to FuriHalSpiHandle
*/
void cc1101_reset(FuriHalSpiBusHandle* handle);
/** Get status
*
* @param handle - pointer to FuriHalSpiHandle
*
* @return CC1101Status structure
*/
CC1101Status cc1101_get_status(FuriHalSpiBusHandle* handle);
/** Enable shutdown mode
*
* @param handle - pointer to FuriHalSpiHandle
*/
void cc1101_shutdown(FuriHalSpiBusHandle* handle);
/** Get Partnumber
*
* @param handle - pointer to FuriHalSpiHandle
*
* @return part number id
*/
uint8_t cc1101_get_partnumber(FuriHalSpiBusHandle* handle);
/** Get Version
*
* @param handle - pointer to FuriHalSpiHandle
*
* @return version
*/
uint8_t cc1101_get_version(FuriHalSpiBusHandle* handle);
/** Get raw RSSI value
*
* @param handle - pointer to FuriHalSpiHandle
*
* @return rssi value
*/
uint8_t cc1101_get_rssi(FuriHalSpiBusHandle* handle);
/** Calibrate oscillator
*
* @param handle - pointer to FuriHalSpiHandle
*/
void cc1101_calibrate(FuriHalSpiBusHandle* handle);
/** Switch to idle
*
* @param handle - pointer to FuriHalSpiHandle
*/
void cc1101_switch_to_idle(FuriHalSpiBusHandle* handle);
/** Switch to RX
*
* @param handle - pointer to FuriHalSpiHandle
*/
void cc1101_switch_to_rx(FuriHalSpiBusHandle* handle);
/** Switch to TX
*
* @param handle - pointer to FuriHalSpiHandle
*/
void cc1101_switch_to_tx(FuriHalSpiBusHandle* handle);
/** Flush RX FIFO
*
* @param handle - pointer to FuriHalSpiHandle
*/
void cc1101_flush_rx(FuriHalSpiBusHandle* handle);
/** Flush TX FIFO
*
* @param handle - pointer to FuriHalSpiHandle
*/
void cc1101_flush_tx(FuriHalSpiBusHandle* handle);
/** Set Frequency
*
* @param handle - pointer to FuriHalSpiHandle
* @param value - frequency in herz
*
* @return real frequency that were synthesized
*/
uint32_t cc1101_set_frequency(FuriHalSpiBusHandle* handle, uint32_t value);
/** Set Intermediate Frequency
*
* @param handle - pointer to FuriHalSpiHandle
* @param value - frequency in herz
*
* @return real inermediate frequency that were synthesized
*/
uint32_t cc1101_set_intermediate_frequency(FuriHalSpiBusHandle* handle, uint32_t value);
/** Set Power Amplifier level table, ramp
*
* @param handle - pointer to FuriHalSpiHandle
* @param value - array of power level values
*/
void cc1101_set_pa_table(FuriHalSpiBusHandle* handle, const uint8_t value[8]);
/** Set Power Amplifier level table, ramp
*
* @param handle - pointer to FuriHalSpiHandle
* @param value - array of power level values
*/
void cc1101_set_pa_table(FuriHalSpiBusHandle* handle, const uint8_t value[8]);
/** Write FIFO
*
* @param handle - pointer to FuriHalSpiHandle
* @param data pointer to byte array
* @param size write bytes count
*
* @return size, written bytes count
*/
uint8_t cc1101_write_fifo(FuriHalSpiBusHandle* handle, const uint8_t* data, uint8_t size);
/** Read FIFO
*
* @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);
#ifdef __cplusplus
}
#endif