hi All,
currently I'm working with CC115l with MSPM0 and have some difficulties to send some messages. I have already evaluate the circuit using using SmartRF via CC debugger and it successfully work with one of legacy rf receiver.
could you please rereview my following code and please help to develop a proper program flow.
Kind regards
Staneslouse
/* * Copyright (c) 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ti/driverlib/dl_spi.h" #include "ti/driverlib/m0p/dl_core.h" #include "ti_msp_dl_config.h" #include <sys/_intsup.h> #include <sys/_stdint.h> /* Data for SPI to transmit and receive */ volatile uint8_t gData; // volatile uint8_t setting_Data; // volatile uint8_t parring_Data; // volatile uint8_t relayOn_Data; #define SIDLE 0x36 // CC115L Strobe for Idle #define SFSTXON 0x31 // CC115L frequency calibration #define STX 0x35 // CC115L enable transmite uint8_t cc115L_Rf_init_Settings[100] = {0x00, 0x2E, 0x01, 0x2E, 0x02, 0x06, 0x03, 0x47, 0x04, 0xAC, 0x05, 0x69, 0x06, 0x06, 0x07, 0x00, 0x08, 0x04, 0x09, 0x00, 0x0A, 0x00, 0x0B, 0x00, 0x0C, 0x00, 0x0D, 0x10, 0x0E, 0x12, 0x0F, 0x34, 0x10, 0xF6, 0x11, 0x37, 0x12, 0x31, 0x13, 0x42, 0x14, 0xE5, 0x15, 0x14, 0x16, 0x00, 0x17, 0x30, 0x18, 0x18, 0x19, 0x00, 0x1A, 0x00, 0x1B, 0x00, 0x1C, 0x00, 0x1D, 0x00, 0x1E, 0x00, 0x1F, 0x00, 0x20, 0x00, 0x21, 0x00, 0x22, 0x11, 0x23, 0xE9, 0x24, 0x2A, 0x25, 0x00, 0x26, 0x1F, 0x27, 0x00, 0x28, 0x00, 0x29, 0x59, 0x2A, 0x7F, 0x2B, 0x3F, 0x2C, 0x81, 0x2D, 0x35, 0x2E, 0x09, 0x2F, 0x00, 0x7E, 0x3F, 0x00, 0x84, }; uint8_t cc115L_Rf_paring_message[7] = {0x7F, 0x69, 0xa5, 0x56, 0x55, 0x66, 0x99, }; uint8_t cc115L_Rf_relay_on_message[7] = {0x7F, 0x69, 0xa5, 0x55, 0x55, 0x66, 0xa5, }; /*SPI commands send to initiate CC115L */ void CC115L_init(void){ DL_GPIO_clearPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN); delay_cycles(20000); int i = 0; for (i = 0; i < 100; i++) { // while (DL_SPI_isBusy(SPI_0_INST)) // ; //setting_Data = cc115L_Rf_init_Settings[i]; DL_SPI_transmitData8(SPI_0_INST, cc115L_Rf_init_Settings[i]); } DL_GPIO_setPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN); } /* SPI send Idle Strobe*/ void SPI_send_Idle_Strobe(void){ // while (DL_SPI_isBusy(SPI_0_INST)) // ; DL_SPI_transmitData8(SPI_0_INST, SIDLE); } /* SPI send frequency calibration Strobe*/ void SPI_send_SFSTXON_Strobe(void){ // while (DL_SPI_isBusy(SPI_0_INST)) // ; DL_SPI_transmitData8(SPI_0_INST, SFSTXON); } /* SPI send TX Strobe*/ void SPI_send_TX_Strobe(void){ // while (DL_SPI_isBusy(SPI_0_INST)) // ; DL_SPI_transmitData8(SPI_0_INST, STX); } void SPI_send_relay_On_message(void){ DL_GPIO_clearPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN); int j = 0; for (j = 0; j < 7; j++) { // while (DL_SPI_isBusy(SPI_0_INST)) // ; //relayOn_Data = cc115L_Rf_relay_on_message[j]; DL_SPI_transmitData8(SPI_0_INST, cc115L_Rf_relay_on_message[j]); } DL_GPIO_setPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN); } void SPI_send_pair_message(void){ DL_GPIO_clearPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN); int k = 0; for (k = 0; k < 7; k++) { // while (DL_SPI_isBusy(SPI_0_INST)) // ; DL_SPI_transmitData8(SPI_0_INST, cc115L_Rf_paring_message[k]); } DL_GPIO_setPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN); } int main(void) { SYSCFG_DL_init(); NVIC_ClearPendingIRQ(SPI_0_INST_INT_IRQN); NVIC_EnableIRQ(SPI_0_INST_INT_IRQN); CC115L_init(); SPI_send_Idle_Strobe(); //send Idle SPI_send_SFSTXON_Strobe();// send frequency calibration Strobe SPI_send_pair_message();// write to TX FIFO SPI_send_TX_Strobe(); // strobe for transmite //SPI_send_Idle_Strobe(); //send Idle delay_cycles(100); //SPI_send_FSTXON_Strobe();// send frequency calibration Strobe SPI_send_pair_message();// write to TX FIFO SPI_send_TX_Strobe(); // strobe for transmite delay_cycles(100); SPI_send_pair_message();// write to TX FIFO SPI_send_TX_Strobe(); // strobe for transmite delay_cycles(100); //SPI_send_Idle_Strobe(); SPI_send_relay_On_message(); SPI_send_TX_Strobe(); SPI_send_Idle_Strobe(); //gData = 1; while (1) { /* Wait for interrupt until a push button is pressed */ __WFI(); } } void SPI_0_INST_IRQHandler(void) { switch (DL_SPI_getPendingInterrupt(SPI_0_INST)) { case DL_SPI_IIDX_RX: //DL_GPIO_clearPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN); /* Read RX FIFO and echo it back to the SPI Controller */ // gData = DL_SPI_receiveData8(SPI_0_INST); // SPI_send_pair_message(); // SPI_send_relay_On_message(); /* Toggle the Blue LED after data reception */ DL_GPIO_togglePins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN); break; default: break; } }