static int at86rf212_set_channel(struct at86rf230_local *lp, u8 page, u8 channel) { int rc; if (channel == 0) rc = at86rf230_write_subreg(lp, SR_SUB_MODE, 0); else rc = at86rf230_write_subreg(lp, SR_SUB_MODE, 1); if (rc < 0) return rc; if (page == 0) { rc = at86rf230_write_subreg(lp, SR_BPSK_QPSK, 0); lp->data->rssi_base_val = -100; } else { rc = at86rf230_write_subreg(lp, SR_BPSK_QPSK, 1); lp->data->rssi_base_val = -98; } if (rc < 0) return rc; rc = at86rf212_update_cca_ed_level(lp, lp->data->rssi_base_val); if (rc < 0) return rc; /* This sets the symbol_duration according frequency on the 212. * TODO move this handling while set channel and page in cfg802154. * We can do that, this timings are according 802.15.4 standard. * If we do that in cfg802154, this is a more generic calculation. * * This should also protected from ifs_timer. Means cancel timer and * init with a new value. For now, this is okay. */ if (channel == 0) { if (page == 0) { /* SUB:0 and BPSK:0 -> BPSK-20 */ lp->hw->phy->symbol_duration = 50; } else { /* SUB:1 and BPSK:0 -> BPSK-40 */ lp->hw->phy->symbol_duration = 25; } } else { if (page == 0) /* SUB:0 and BPSK:1 -> OQPSK-100/200/400 */ lp->hw->phy->symbol_duration = 40; else /* SUB:1 and BPSK:1 -> OQPSK-250/500/1000 */ lp->hw->phy->symbol_duration = 16; } lp->hw->phy->lifs_period = IEEE802154_LIFS_PERIOD * lp->hw->phy->symbol_duration; lp->hw->phy->sifs_period = IEEE802154_SIFS_PERIOD * lp->hw->phy->symbol_duration; return at86rf230_write_subreg(lp, SR_CHANNEL, channel); }
static void at86rf230_stop(struct ieee802154_hw *hw) { struct at86rf230_local *lp = hw->priv; u8 csma_seed[2]; at86rf230_sync_state_change(lp, STATE_FORCE_TRX_OFF); disable_irq(lp->spi->irq); /* It's recommended to set random new csma_seeds before sleep state. * Makes only sense in the stop callback, not doing this inside of * at86rf230_sleep, this is also used when we don't transmit afterwards * when calling start callback again. */ get_random_bytes(csma_seed, ARRAY_SIZE(csma_seed)); at86rf230_write_subreg(lp, SR_CSMA_SEED_0, csma_seed[0]); at86rf230_write_subreg(lp, SR_CSMA_SEED_1, csma_seed[1]); at86rf230_sleep(lp); }
static int at86rf23x_set_channel(struct at86rf230_local *lp, u8 page, u8 channel) { return at86rf230_write_subreg(lp, SR_CHANNEL, channel); }