HOW TO COMPLETE THE ARGUMENTS OF A GENERATED FONCTION ?

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

HOW TO COMPLETE THE ARGUMENTS OF A GENERATED FONCTION ?

Jump to solution
903 Views
robert2000
Contributor II

/* I Use for the Fist time KDSK with Processor Expert. I was able to easily create a project, create and configure LDD Component, Generated software,built the project, define and use new fonction, use generated events files

   BUT I D'ONT UNDERSTAND HOW TO COMPLETE THE ARGUMENTS OF A GENERATED FONCTION.

For exemple I create a Master SPI LDD COmponent called My_SPI and I try to use the generated fileMy_SPI_SendBlock(); Below are 4 diefferents Try all Wrong.

   */

 

#ifdef MY_SPI_TRY1

/*Fonction is copy and paste from file My_SPI.h*/

** ===================================================================

** Method : My_SPI_SendBlock (component SPIMaster_LDD)

*/

/*!

** @brief

** This method sends a block of characters. The method returns

** ERR_BUSY when the previous block transmission is not

** completed. The method <CancelBlockTransmission> can be used

** to cancel a transmit operation.

** @param

** DeviceDataPtr - Device data structure

** pointer returned by <Init> method.

** @param

** BufferPtr - Pointer to the block of data

** to send.

** @param

** Size - Number of characters in the buffer.

** @return

** - Error code, possible codes:

** ERR_OK - OK

** ERR_SPEED - This device does not work in

** the active clock configuration

** ERR_DISABLED - Component is disabled

** ERR_BUSY - The previous transmit request is

** pending

*/

/* ===================================================================*/

uint16_t Size=3;

LDD_TError My_SPI_SendBlock(LDD_TDeviceData *DeviceDataPtr, LDD_TData *Com_depart_SPIPtr, uint16_t Size);

/*1) This Solution is accepted by the build Project Process but looks like a new protype and not a parameter allocation */

#endif // MY_SPI_TRY1

 

#ifdef MY_SPI_TRY2

/*Fonction is copy and paste from file My_SPI.h*/

uint16_t Size=3;

LDD_TError My_SPI_SendBlock(LDD_TDeviceData *DeviceDataPtr, LDD_TData *Com_depart_SPI[0]Ptr, uint16_t Size);

/*2) This Solution is rejected by the build Project Process: expected ';', ',' or ')' */

#endif // MY_SPI_TRY2

 

#ifdef MY_SPI_TRY3

/*Fonction is copy and paste from file My_SPI.h*/

LDD_TError My_SPI_SendBlock(#ifdef MY_SPI_TRY3

LDD_TError My_SPI_SendBlock(LDD_TDeviceData *DeviceDataPtr, LDD_TData *Com_depart_SPIPtr, 3);

   /*3) This Solution is rejected by the build Project Process: expected declaration specifiers or '...' before numeric constant */

#endif // MY_SPI_TRY3);

 

#ifdef MY_SPI_TRY4

/*Fonction is drag from Component file My_SPI:SPIMaster_LDD*/

My_SPI_SendBlock(LDD_TDeviceData *DeviceDataPtr, LDD_TData *Com_depart_SPIPtr, 3);

/*4) This Solution is rejected by the build Project Process:

expected expression before 'LDD_TDeviceData'

too few arguments to function 'My_SPI_SendBlock' */

#endif // MY_SPI_TRY4

 

  /* I find out no documentation to explain how to use these parameters. Could somebody help me. Thanks a lot .Robert */

Labels (1)
1 Solution
552 Views
adriancano
NXP Employee
NXP Employee

Hi,

It seems that you are using an LDD component driver and not and KSDK driver.

These components use the Processor Expert drivers known as LDD; commonly these drivers has the same structure, when are for Communication peripheral components such as SPI, UART or I2C. The common function looks like:

Function_to_send_data(LDD_TDeviceData *DeviceDataPtr, LDD_TData *BufferPtr, uint16_t Size)

where the parameters are:

DeviceDataPtr: Pointer to LDD_TDeviceData - Device data structure pointer returned by Init method.

BufferPtr: Pointer to LDD_TData - Pointer to the block of data to send.

Size:uint16_t - Number of characters in the buffer.

Here is an example of the typical usage of this function:

  • Declare a LDD_TDeviceData pointer:

          LDD_TDeviceData *MySPIPtr;

  • Declare the out data buffer, this is the buffer sent by the function: (in this case the buffer is size=4)

          uint8_t OutData[4] = "0123";

  • Declare size variable, or a #define

          uint8_t size = 4;          or          #define SIZE 4

  • In your main code you need to call firs the init function that will return the pointer to your device:

          MySPIPtr = SM1_Init(NULL);

  • Use the function as follows:

          SM1_SendBlock(MySPIPtr, OutData, SIZE);

If you have installed KDS v1.1.1 you can find the Component User Guide under this path:

<install_folder>\KDS_1.1.1\eclipse\ProcessorExpert\Help\ComponentUserGuides

There you can find a document for each LDD component including typical usage examples.

I hope this information can help you.

Regards,

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. It would be nice!

-----------------------------------------------------------------------------------------------------------------------

View solution in original post

3 Replies
553 Views
adriancano
NXP Employee
NXP Employee

Hi,

It seems that you are using an LDD component driver and not and KSDK driver.

These components use the Processor Expert drivers known as LDD; commonly these drivers has the same structure, when are for Communication peripheral components such as SPI, UART or I2C. The common function looks like:

Function_to_send_data(LDD_TDeviceData *DeviceDataPtr, LDD_TData *BufferPtr, uint16_t Size)

where the parameters are:

DeviceDataPtr: Pointer to LDD_TDeviceData - Device data structure pointer returned by Init method.

BufferPtr: Pointer to LDD_TData - Pointer to the block of data to send.

Size:uint16_t - Number of characters in the buffer.

Here is an example of the typical usage of this function:

  • Declare a LDD_TDeviceData pointer:

          LDD_TDeviceData *MySPIPtr;

  • Declare the out data buffer, this is the buffer sent by the function: (in this case the buffer is size=4)

          uint8_t OutData[4] = "0123";

  • Declare size variable, or a #define

          uint8_t size = 4;          or          #define SIZE 4

  • In your main code you need to call firs the init function that will return the pointer to your device:

          MySPIPtr = SM1_Init(NULL);

  • Use the function as follows:

          SM1_SendBlock(MySPIPtr, OutData, SIZE);

If you have installed KDS v1.1.1 you can find the Component User Guide under this path:

<install_folder>\KDS_1.1.1\eclipse\ProcessorExpert\Help\ComponentUserGuides

There you can find a document for each LDD component including typical usage examples.

I hope this information can help you.

Regards,

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. It would be nice!

-----------------------------------------------------------------------------------------------------------------------

552 Views
robert2000
Contributor II

Hi, thanks a lot. Extremely clear.

Just a side question : Yes I am using an LDD component driver and not and KSDK driver.But what do you means by using the KSDK driver.

Is it using an OS Component like MQXlite for exemple ?

Best Regards

0 Kudos
552 Views
adriancano
NXP Employee
NXP Employee

Hi,

Have a look at this conversation, it would probably solves your queries.

SDK vs PDD(without SDK)

Best Regards,

Adrian