Doubt with lpspi_transfer_s32k148

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Doubt with lpspi_transfer_s32k148

357 Views
RishikeshB
Contributor II

Hello NXP

I tried the Following example , Can you please explain in short and in this what data are we sending exactly and how can we change the data that we are sending ??


/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "clockMan1.h"
#include "pin_mux.h"
#include "Send.h"
#include "Receive.h"
#include "adConv1.h"
#include "dmaController1.h"
#include "flexTimer_pwm1.h"
#if CPU_INIT_CONFIG
#include "Init_Config.h"
#endif
#define BUFFER_SIZE 1U
#define TIMEOUT 10U
volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */

#include <stdint.h>
#include <stdbool.h>

/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - __start (startup asm routine)
* - __init_hardware()
* - main()
* - PE_low_level_init()
* - Common_Init()
* - Peripherals_Init()
*/
int main(void)
{
/* Write your local variable definition here */

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/

ftm_state_t ftmStateStruct;
uint8_t masterDataSend;
uint8_t masterDataReceive;
lpspi_state_t masterState;
// uint8_t slaveDataReceive;
uint16_t adcRead;
//uint8_t slaveDataSend;
// lpspi_state_t slaveState;
/* Initialize and configure clocks
* - see clock manager component for details
*/
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

/* Initialize pins
* - See PinSettings component for more info
*/

/* Example Description
* Potentiometer voltage is read using ADC0- channel 0. The value is send to
* LPSPI1 from LPSPI0. The read value represent duty for PWM (FTM0-channel 0).
* SPI wiring:
* B0-D3
* B2-D0
* E1-D2
* B4-D1
*/
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
/* Initialize LPSPI0 (Send)*/
LPSPI_DRV_MasterInit(SEND, &masterState, &Send_MasterConfig0);
/* Initialize LPSPI1 (Receive)*/
// LPSPI_DRV_SlaveInit(RECEIVE, &slaveState, &Receive_SlaveConfig0);
/* Initialize ADC */
ADC_DRV_ConfigConverter(INST_ADCONV1, &adConv1_ConvConfig0);
/* Initialize FTM */
FTM_DRV_Init(INST_FLEXTIMER_PWM1, &flexTimer_pwm1_InitConfig, &ftmStateStruct);
FTM_DRV_InitPwm(INST_FLEXTIMER_PWM1, &flexTimer_pwm1_PwmConfig);

while(1)
{
ADC_DRV_ConfigChan(INST_ADCONV1, 0U, &adConv1_ChnConfig0);
ADC_DRV_WaitConvDone(INST_ADCONV1);
/* Store the channel result into a local variable slaveDataSend*/
ADC_DRV_GetChanResult(INST_ADCONV1, 0U, &adcRead);

LPSPI_DRV_MasterTransferBlocking(SEND, &masterDataSend, &masterDataReceive, BUFFER_SIZE, TIMEOUT);

}
/* Write your code here */
/* For example: for(;;) { } */

/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

 

 

 

Tags (1)
0 Kudos
2 Replies

346 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

You have stated it in the middle:

/* Example Description
* Potentiometer voltage is read using ADC0- channel 0. The value is send to
* LPSPI1 from LPSPI0. The read value represent duty for PWM (FTM0-channel 0).
* SPI wiring:
* B0-D3
* B2-D0
* E1-D2
* B4-D1
*/

0 Kudos

337 Views
RishikeshB
Contributor II

Hi

want to change the data that is being getting transferred can you please tell me how can i do that

 

0 Kudos