Added const keywords
This commit is contained in:
parent
18485ffefd
commit
a1f2c93cf6
@ -628,7 +628,7 @@ int CMT2300A_GetRssiDBm(void)
|
|||||||
* for fast frequency hopping operation.
|
* for fast frequency hopping operation.
|
||||||
* @param nChann: the frequency channel
|
* @param nChann: the frequency channel
|
||||||
* *********************************************************/
|
* *********************************************************/
|
||||||
void CMT2300A_SetFrequencyChannel(uint8_t nChann)
|
void CMT2300A_SetFrequencyChannel(const uint8_t nChann)
|
||||||
{
|
{
|
||||||
CMT2300A_WriteReg(CMT2300A_CUS_FREQ_CHNL, nChann);
|
CMT2300A_WriteReg(CMT2300A_CUS_FREQ_CHNL, nChann);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ void CMT2300A_EnableTxDinInvert(bool bEnable);
|
|||||||
bool CMT2300A_IsExist(void);
|
bool CMT2300A_IsExist(void);
|
||||||
uint8_t CMT2300A_GetRssiCode(void);
|
uint8_t CMT2300A_GetRssiCode(void);
|
||||||
int CMT2300A_GetRssiDBm(void);
|
int CMT2300A_GetRssiDBm(void);
|
||||||
void CMT2300A_SetFrequencyChannel(uint8_t nChann);
|
void CMT2300A_SetFrequencyChannel(const uint8_t nChann);
|
||||||
void CMT2300A_SetFrequencyStep(uint8_t nOffset);
|
void CMT2300A_SetFrequencyStep(uint8_t nOffset);
|
||||||
void CMT2300A_SetPayloadLength(uint16_t nLength);
|
void CMT2300A_SetPayloadLength(uint16_t nLength);
|
||||||
void CMT2300A_EnableLfosc(bool bEnable);
|
void CMT2300A_EnableLfosc(bool bEnable);
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
* @name CMT2300A_InitSpi
|
* @name CMT2300A_InitSpi
|
||||||
* @desc Initializes the CMT2300A SPI interface.
|
* @desc Initializes the CMT2300A SPI interface.
|
||||||
* *********************************************************/
|
* *********************************************************/
|
||||||
void CMT2300A_InitSpi(int8_t pin_sdio, int8_t pin_clk, int8_t pin_cs, int8_t pin_fcs, uint32_t spi_speed)
|
void CMT2300A_InitSpi(const int8_t pin_sdio, const int8_t pin_clk, const int8_t pin_cs, const int8_t pin_fcs, const uint32_t spi_speed)
|
||||||
{
|
{
|
||||||
cmt_spi3_init(pin_sdio, pin_clk, pin_cs, pin_fcs, spi_speed);
|
cmt_spi3_init(pin_sdio, pin_clk, pin_cs, pin_fcs, spi_speed);
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ void CMT2300A_InitSpi(int8_t pin_sdio, int8_t pin_clk, int8_t pin_cs, int8_t pin
|
|||||||
* @param addr: register address
|
* @param addr: register address
|
||||||
* @return Register value
|
* @return Register value
|
||||||
* *********************************************************/
|
* *********************************************************/
|
||||||
uint8_t CMT2300A_ReadReg(uint8_t addr)
|
uint8_t CMT2300A_ReadReg(const uint8_t addr)
|
||||||
{
|
{
|
||||||
return cmt_spi3_read(addr);
|
return cmt_spi3_read(addr);
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ uint8_t CMT2300A_ReadReg(uint8_t addr)
|
|||||||
* @param addr: register address
|
* @param addr: register address
|
||||||
* dat: register value
|
* dat: register value
|
||||||
* *********************************************************/
|
* *********************************************************/
|
||||||
void CMT2300A_WriteReg(uint8_t addr, uint8_t dat)
|
void CMT2300A_WriteReg(const uint8_t addr, const uint8_t dat)
|
||||||
{
|
{
|
||||||
cmt_spi3_write(addr, dat);
|
cmt_spi3_write(addr, dat);
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ void CMT2300A_WriteReg(uint8_t addr, uint8_t dat)
|
|||||||
* @param buf: buffer where to copy the FIFO read data
|
* @param buf: buffer where to copy the FIFO read data
|
||||||
* len: number of bytes to be read from the FIFO
|
* len: number of bytes to be read from the FIFO
|
||||||
* *********************************************************/
|
* *********************************************************/
|
||||||
void CMT2300A_ReadFifo(uint8_t buf[], uint16_t len)
|
void CMT2300A_ReadFifo(uint8_t buf[], const uint16_t len)
|
||||||
{
|
{
|
||||||
cmt_spi3_read_fifo(buf, len);
|
cmt_spi3_read_fifo(buf, len);
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ void CMT2300A_ReadFifo(uint8_t buf[], uint16_t len)
|
|||||||
* @param buf: buffer containing data to be put on the FIFO
|
* @param buf: buffer containing data to be put on the FIFO
|
||||||
* len: number of bytes to be written to the FIFO
|
* len: number of bytes to be written to the FIFO
|
||||||
* *********************************************************/
|
* *********************************************************/
|
||||||
void CMT2300A_WriteFifo(const uint8_t buf[], uint16_t len)
|
void CMT2300A_WriteFifo(const uint8_t buf[], const uint16_t len)
|
||||||
{
|
{
|
||||||
cmt_spi3_write_fifo(buf, len);
|
cmt_spi3_write_fifo(buf, len);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,13 +36,13 @@ extern "C" {
|
|||||||
#define CMT2300A_GetTickCount() millis()
|
#define CMT2300A_GetTickCount() millis()
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
|
|
||||||
void CMT2300A_InitSpi(int8_t pin_sdio, int8_t pin_clk, int8_t pin_cs, int8_t pin_fcs, uint32_t spi_speed);
|
void CMT2300A_InitSpi(const int8_t pin_sdio, const int8_t pin_clk, const int8_t pin_cs, const int8_t pin_fcs, const uint32_t spi_speed);
|
||||||
|
|
||||||
uint8_t CMT2300A_ReadReg(uint8_t addr);
|
uint8_t CMT2300A_ReadReg(const uint8_t addr);
|
||||||
void CMT2300A_WriteReg(uint8_t addr, uint8_t dat);
|
void CMT2300A_WriteReg(const uint8_t addr, const uint8_t dat);
|
||||||
|
|
||||||
void CMT2300A_ReadFifo(uint8_t buf[], uint16_t len);
|
void CMT2300A_ReadFifo(uint8_t buf[], const uint16_t len);
|
||||||
void CMT2300A_WriteFifo(const uint8_t buf[], uint16_t len);
|
void CMT2300A_WriteFifo(const uint8_t buf[], const uint16_t len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
#include "cmt2300a_params_860.h"
|
#include "cmt2300a_params_860.h"
|
||||||
#include "cmt2300a_params_900.h"
|
#include "cmt2300a_params_900.h"
|
||||||
|
|
||||||
CMT2300A::CMT2300A(uint8_t pin_sdio, uint8_t pin_clk, uint8_t pin_cs, uint8_t pin_fcs, uint32_t spi_speed)
|
CMT2300A::CMT2300A(const uint8_t pin_sdio, const uint8_t pin_clk, const uint8_t pin_cs, const uint8_t pin_fcs, const uint32_t spi_speed)
|
||||||
{
|
{
|
||||||
_pin_sdio = pin_sdio;
|
_pin_sdio = pin_sdio;
|
||||||
_pin_clk = pin_clk;
|
_pin_clk = pin_clk;
|
||||||
@ -58,7 +58,7 @@ bool CMT2300A::available(void)
|
|||||||
) & CMT2300A_ReadReg(CMT2300A_CUS_INT_FLAG);
|
) & CMT2300A_ReadReg(CMT2300A_CUS_INT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMT2300A::read(void* buf, uint8_t len)
|
void CMT2300A::read(void* buf, const uint8_t len)
|
||||||
{
|
{
|
||||||
// Fetch the payload
|
// Fetch the payload
|
||||||
CMT2300A_ReadFifo(static_cast<uint8_t*>(buf), len);
|
CMT2300A_ReadFifo(static_cast<uint8_t*>(buf), len);
|
||||||
@ -66,7 +66,7 @@ void CMT2300A::read(void* buf, uint8_t len)
|
|||||||
CMT2300A_ClearInterruptFlags();
|
CMT2300A_ClearInterruptFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMT2300A::write(const uint8_t* buf, uint8_t len)
|
bool CMT2300A::write(const uint8_t* buf, const uint8_t len)
|
||||||
{
|
{
|
||||||
CMT2300A_GoStby();
|
CMT2300A_GoStby();
|
||||||
CMT2300A_ClearInterruptFlags();
|
CMT2300A_ClearInterruptFlags();
|
||||||
@ -101,7 +101,7 @@ bool CMT2300A::write(const uint8_t* buf, uint8_t len)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMT2300A::setChannel(uint8_t channel)
|
void CMT2300A::setChannel(const uint8_t channel)
|
||||||
{
|
{
|
||||||
CMT2300A_SetFrequencyChannel(channel);
|
CMT2300A_SetFrequencyChannel(channel);
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ int CMT2300A::getRssiDBm()
|
|||||||
return CMT2300A_GetRssiDBm();
|
return CMT2300A_GetRssiDBm();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMT2300A::setPALevel(int8_t level)
|
bool CMT2300A::setPALevel(const int8_t level)
|
||||||
{
|
{
|
||||||
uint16_t Tx_dBm_word;
|
uint16_t Tx_dBm_word;
|
||||||
switch (level) {
|
switch (level) {
|
||||||
|
|||||||
@ -18,7 +18,7 @@ enum FrequencyBand_t {
|
|||||||
|
|
||||||
class CMT2300A {
|
class CMT2300A {
|
||||||
public:
|
public:
|
||||||
CMT2300A(uint8_t pin_sdio, uint8_t pin_clk, uint8_t pin_cs, uint8_t pin_fcs, uint32_t _spi_speed = CMT_SPI_SPEED);
|
CMT2300A(const uint8_t pin_sdio, const uint8_t pin_clk, const uint8_t pin_cs, const uint8_t pin_fcs, const uint32_t _spi_speed = CMT_SPI_SPEED);
|
||||||
|
|
||||||
bool begin(void);
|
bool begin(void);
|
||||||
|
|
||||||
@ -62,15 +62,15 @@ public:
|
|||||||
* in one call is 32 (for dynamic payload lengths) or whatever number was
|
* in one call is 32 (for dynamic payload lengths) or whatever number was
|
||||||
* previously passed to setPayloadSize() (for static payload lengths).
|
* previously passed to setPayloadSize() (for static payload lengths).
|
||||||
*/
|
*/
|
||||||
void read(void* buf, uint8_t len);
|
void read(void* buf, const uint8_t len);
|
||||||
|
|
||||||
bool write(const uint8_t* buf, uint8_t len);
|
bool write(const uint8_t* buf, const uint8_t len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set RF communication channel. The frequency used by a channel is
|
* Set RF communication channel. The frequency used by a channel is
|
||||||
* @param channel Which RF channel to communicate on, 0-254
|
* @param channel Which RF channel to communicate on, 0-254
|
||||||
*/
|
*/
|
||||||
void setChannel(uint8_t channel);
|
void setChannel(const uint8_t channel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get RF communication channel
|
* Get RF communication channel
|
||||||
@ -90,7 +90,7 @@ public:
|
|||||||
|
|
||||||
int getRssiDBm();
|
int getRssiDBm();
|
||||||
|
|
||||||
bool setPALevel(int8_t level);
|
bool setPALevel(const int8_t level);
|
||||||
|
|
||||||
bool rxFifoAvailable();
|
bool rxFifoAvailable();
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ SemaphoreHandle_t paramLock = NULL;
|
|||||||
|
|
||||||
spi_device_handle_t spi_reg, spi_fifo;
|
spi_device_handle_t spi_reg, spi_fifo;
|
||||||
|
|
||||||
void cmt_spi3_init(int8_t pin_sdio, int8_t pin_clk, int8_t pin_cs, int8_t pin_fcs, uint32_t spi_speed)
|
void cmt_spi3_init(const int8_t pin_sdio, const int8_t pin_clk, const int8_t pin_cs, const int8_t pin_fcs, const uint32_t spi_speed)
|
||||||
{
|
{
|
||||||
paramLock = xSemaphoreCreateMutex();
|
paramLock = xSemaphoreCreateMutex();
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ void cmt_spi3_init(int8_t pin_sdio, int8_t pin_clk, int8_t pin_cs, int8_t pin_fc
|
|||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmt_spi3_write(uint8_t addr, uint8_t dat)
|
void cmt_spi3_write(const uint8_t addr, const uint8_t dat)
|
||||||
{
|
{
|
||||||
uint8_t tx_data;
|
uint8_t tx_data;
|
||||||
tx_data = ~dat;
|
tx_data = ~dat;
|
||||||
@ -84,7 +84,7 @@ void cmt_spi3_write(uint8_t addr, uint8_t dat)
|
|||||||
delayMicroseconds(100);
|
delayMicroseconds(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t cmt_spi3_read(uint8_t addr)
|
uint8_t cmt_spi3_read(const uint8_t addr)
|
||||||
{
|
{
|
||||||
uint8_t rx_data;
|
uint8_t rx_data;
|
||||||
spi_transaction_t t = {
|
spi_transaction_t t = {
|
||||||
@ -102,7 +102,7 @@ uint8_t cmt_spi3_read(uint8_t addr)
|
|||||||
return rx_data;
|
return rx_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmt_spi3_write_fifo(const uint8_t* buf, uint16_t len)
|
void cmt_spi3_write_fifo(const uint8_t* buf, const uint16_t len)
|
||||||
{
|
{
|
||||||
uint8_t tx_data;
|
uint8_t tx_data;
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ void cmt_spi3_write_fifo(const uint8_t* buf, uint16_t len)
|
|||||||
SPI_PARAM_UNLOCK();
|
SPI_PARAM_UNLOCK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmt_spi3_read_fifo(uint8_t* buf, uint16_t len)
|
void cmt_spi3_read_fifo(uint8_t* buf, const uint16_t len)
|
||||||
{
|
{
|
||||||
uint8_t rx_data;
|
uint8_t rx_data;
|
||||||
|
|
||||||
|
|||||||
@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void cmt_spi3_init(int8_t pin_sdio, int8_t pin_clk, int8_t pin_cs, int8_t pin_fcs, uint32_t spi_speed);
|
void cmt_spi3_init(const int8_t pin_sdio, const int8_t pin_clk, const int8_t pin_cs, const int8_t pin_fcs, const uint32_t spi_speed);
|
||||||
|
|
||||||
void cmt_spi3_write(uint8_t addr, uint8_t dat);
|
void cmt_spi3_write(const uint8_t addr, const uint8_t dat);
|
||||||
uint8_t cmt_spi3_read(uint8_t addr);
|
uint8_t cmt_spi3_read(const uint8_t addr);
|
||||||
|
|
||||||
void cmt_spi3_write_fifo(const uint8_t* p_buf, uint16_t len);
|
void cmt_spi3_write_fifo(const uint8_t* p_buf, const uint16_t len);
|
||||||
void cmt_spi3_read_fifo(uint8_t* p_buf, uint16_t len);
|
void cmt_spi3_read_fifo(uint8_t* p_buf, const uint16_t len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -52,7 +52,7 @@ uint8_t HoymilesRadio_CMT::getChannelFromFrequency(const uint32_t frequency) con
|
|||||||
return (frequency - _radio->getBaseFrequency()) / getChannelWidth(); // frequency to channel
|
return (frequency - _radio->getBaseFrequency()) / getChannelWidth(); // frequency to channel
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CountryFrequencyList_t> HoymilesRadio_CMT::getCountryFrequencyList()
|
std::vector<CountryFrequencyList_t> HoymilesRadio_CMT::getCountryFrequencyList() const
|
||||||
{
|
{
|
||||||
std::vector<CountryFrequencyList_t> v;
|
std::vector<CountryFrequencyList_t> v;
|
||||||
for (const auto& [key, value] : countryDefinition) {
|
for (const auto& [key, value] : countryDefinition) {
|
||||||
@ -237,7 +237,7 @@ CountryModeId_t HoymilesRadio_CMT::getCountryMode() const
|
|||||||
return _countryMode;
|
return _countryMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HoymilesRadio_CMT::setCountryMode(CountryModeId_t mode)
|
void HoymilesRadio_CMT::setCountryMode(const CountryModeId_t mode)
|
||||||
{
|
{
|
||||||
_radio->setFrequencyBand(countryDefinition.at(mode).Band);
|
_radio->setFrequencyBand(countryDefinition.at(mode).Band);
|
||||||
_countryMode = mode;
|
_countryMode = mode;
|
||||||
|
|||||||
@ -57,14 +57,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
CountryModeId_t getCountryMode() const;
|
CountryModeId_t getCountryMode() const;
|
||||||
void setCountryMode(CountryModeId_t mode);
|
void setCountryMode(const CountryModeId_t mode);
|
||||||
|
|
||||||
uint32_t getInvBootFrequency() const;
|
uint32_t getInvBootFrequency() const;
|
||||||
|
|
||||||
uint32_t getFrequencyFromChannel(const uint8_t channel) const;
|
uint32_t getFrequencyFromChannel(const uint8_t channel) const;
|
||||||
uint8_t getChannelFromFrequency(const uint32_t frequency) const;
|
uint8_t getChannelFromFrequency(const uint32_t frequency) const;
|
||||||
|
|
||||||
std::vector<CountryFrequencyList_t> getCountryFrequencyList();
|
std::vector<CountryFrequencyList_t> getCountryFrequencyList() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ARDUINO_ISR_ATTR handleInt1();
|
void ARDUINO_ISR_ATTR handleInt1();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user