[SX126x] Rework SPI config interface
This commit is contained in:
parent
5dfaf00302
commit
1ce5e75ab9
1 changed files with 18 additions and 12 deletions
|
@ -14,12 +14,15 @@ int16_t SX126x::begin(uint8_t cr, uint8_t syncWord, uint16_t preambleLength, flo
|
|||
this->mod->init();
|
||||
this->mod->hal->pinMode(this->mod->getIrq(), this->mod->hal->GpioModeInput);
|
||||
this->mod->hal->pinMode(this->mod->getGpio(), this->mod->hal->GpioModeInput);
|
||||
this->mod->SPIreadCommand = RADIOLIB_SX126X_CMD_READ_REGISTER;
|
||||
this->mod->SPIwriteCommand = RADIOLIB_SX126X_CMD_WRITE_REGISTER;
|
||||
this->mod->SPInopCommand = RADIOLIB_SX126X_CMD_NOP;
|
||||
this->mod->SPIstatusCommand = RADIOLIB_SX126X_CMD_GET_STATUS;
|
||||
this->mod->SPIstreamType = true;
|
||||
this->mod->SPIparseStatusCb = SPIparseStatus;
|
||||
this->mod->spiConfig.widths[RADIOLIB_MODULE_SPI_WIDTH_ADDR] = 16;
|
||||
this->mod->spiConfig.widths[RADIOLIB_MODULE_SPI_WIDTH_CMD] = 8;
|
||||
this->mod->spiConfig.statusPos = 1;
|
||||
this->mod->spiConfig.cmds[RADIOLIB_MODULE_SPI_COMMAND_READ] = RADIOLIB_SX126X_CMD_READ_REGISTER;
|
||||
this->mod->spiConfig.cmds[RADIOLIB_MODULE_SPI_COMMAND_WRITE] = RADIOLIB_SX126X_CMD_WRITE_REGISTER;
|
||||
this->mod->spiConfig.cmds[RADIOLIB_MODULE_SPI_COMMAND_NOP] = RADIOLIB_SX126X_CMD_NOP;
|
||||
this->mod->spiConfig.cmds[RADIOLIB_MODULE_SPI_COMMAND_STATUS] = RADIOLIB_SX126X_CMD_GET_STATUS;
|
||||
this->mod->spiConfig.stream = true;
|
||||
this->mod->spiConfig.parseStatusCb = SPIparseStatus;
|
||||
|
||||
// try to find the SX126x chip
|
||||
if(!SX126x::findChip(this->chipType)) {
|
||||
|
@ -99,12 +102,15 @@ int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, uint16_t preambleL
|
|||
this->mod->init();
|
||||
this->mod->hal->pinMode(this->mod->getIrq(), this->mod->hal->GpioModeInput);
|
||||
this->mod->hal->pinMode(this->mod->getGpio(), this->mod->hal->GpioModeInput);
|
||||
this->mod->SPIreadCommand = RADIOLIB_SX126X_CMD_READ_REGISTER;
|
||||
this->mod->SPIwriteCommand = RADIOLIB_SX126X_CMD_WRITE_REGISTER;
|
||||
this->mod->SPInopCommand = RADIOLIB_SX126X_CMD_NOP;
|
||||
this->mod->SPIstatusCommand = RADIOLIB_SX126X_CMD_GET_STATUS;
|
||||
this->mod->SPIstreamType = true;
|
||||
this->mod->SPIparseStatusCb = SPIparseStatus;
|
||||
this->mod->spiConfig.widths[RADIOLIB_MODULE_SPI_WIDTH_ADDR] = 16;
|
||||
this->mod->spiConfig.widths[RADIOLIB_MODULE_SPI_WIDTH_CMD] = 8;
|
||||
this->mod->spiConfig.statusPos = 1;
|
||||
this->mod->spiConfig.cmds[RADIOLIB_MODULE_SPI_COMMAND_READ] = RADIOLIB_SX126X_CMD_READ_REGISTER;
|
||||
this->mod->spiConfig.cmds[RADIOLIB_MODULE_SPI_COMMAND_WRITE] = RADIOLIB_SX126X_CMD_WRITE_REGISTER;
|
||||
this->mod->spiConfig.cmds[RADIOLIB_MODULE_SPI_COMMAND_NOP] = RADIOLIB_SX126X_CMD_NOP;
|
||||
this->mod->spiConfig.cmds[RADIOLIB_MODULE_SPI_COMMAND_STATUS] = RADIOLIB_SX126X_CMD_GET_STATUS;
|
||||
this->mod->spiConfig.stream = true;
|
||||
this->mod->spiConfig.parseStatusCb = SPIparseStatus;
|
||||
|
||||
// try to find the SX126x chip
|
||||
if(!SX126x::findChip(this->chipType)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue