void mrf_init(void) { mrf_gpio_init(); // Set up p14 and p21 mrf_spi_init(8, 0, 500000); // 8-bit transfers, CPOL=0/CPHA=0, sclk = 500kHz mrf_reset(); // Hard and soft reset, configure for Tx/Rx // Only enable interrupts after the radio is configured mrf_gpioint_init(); }
/****************************************************************************** mrf_init433 ******************************************************************************* Initializes the RFM12/SI4420 with the default parameters for 433MHz operation. Note: the transceiver is deactivated. Selection of transmit or receive mode must be done after initialization with mrf_setradiotx or mrf_setradiorx; Input: bitrate: data transmission speed in bits per second ******************************************************************************/ void mrf_init433(unsigned long bitrate) { // Init the SPI interface mrf_spi_init(); // Set FFS# high. mrf_setffs(1); // Setup the radio configuration mrf_command(CSCREG|0xD7); // el ef 433MHz 12pF //PMCREG|0xD9, // er ebb es ex dc (initial) mrf_command(FSCREG|0x640); // 434MHz mrf_setdatarate(bitrate); _shadow_PSCREG = 0x4A0; // nINT/VDI is VDI, fast, BW 134KHz, LNA 0dB, RSSI -103dBm mrf_command(PSCREG|_shadow_PSCREG); mrf_command(DFCREG|0xAC); // clock recovery auto lock, clock recovery slow, DQD=4 mrf_command(FRMCREG|0x81); // FIFO interrupt level 8, FIFO fill start condition synchron pattern, !ff, disable sensitive reset //AFCCREG|0x83, // keep offset during receiving, no range restriction, !st, not fine mode, not enable frequency offset register, not enable calculation of offset (initial) mrf_command(AFCCREG|0x00); // disable all AFC options _shadow_TXCCCREG = 0x50; // !mp, 90KHz, 0dB mrf_command(TXCCCREG|_shadow_TXCCCREG); mrf_command(WUTCREG|0x00); // Wake-up timer unused mrf_command(LDCCREG|0x00); // Low duty-cycle not enabled //AFCCREG|0x00, //FRMCREG|0x81 mrf_setradioidle(); mrf_command(0x0000); // Reads the status register. This clears any possible interrupts. }