VDKHelp
In order to start using Analog's VDK, you need to create a new VDK Project:
- Open up VisualDSP++ and click File -> New Project
- Select the General heading on the left, select a directory to put it in, and give it a name. NOTE: If you enter a name first, and then change the directory, a project subdirectory won't be created unless you modify the name again...
- Select the "Multi-threaded application using VDK" and click Next
- Make sure the ADSP-BF537 is selected (should be default)
- Make sure Silicon Revision is Automatic
- Make sure Project output type is Executable File
- Click Next.
- When prompted to create startup code, select No (default) and click Next, then click Finish.
Now we need to add a Thread Type to the project. Select the Kernel tab at the bottom left, expand Threads, right-click Thread Types and select New Thread Type.
- Enter a name for the thread. This will auto-fill the Source File and Header File fields. Just leave these alone.
- MAKE SURE to select C as the language (the default is C++). If this is not done, there will be linker problems when you try to add in the original handy board code.
- Repeat these steps for each thread you want to add.
- Now right-click Boot Threads and select New Boot Thread. Enter a name for it, such as boot_thread. The name you enter must be a valid C identifier name or it'll complain. This boot thread is not a thread in itself, but it refers to an actual thread you created. In this case, it will refer to the one you just created in the previous step. If you expand the newly created boot_thread, you'll see "Thread Type", which is a dropdown list where you can select which of your threads you want to run when you first start the program.
Now we need to add the existing Handy Board code to the project so we can call Handy Board functions.
- Obtain a copy of the current Handy Board code from the network share K drive in the Code folder. Unzip the BF_Handy_Board folder into your VDK project directory.
- Select the Project tab on the bottom left.
- Right-click Source Files and select Add Files to Folder, and navigate into the BF_Handy_Board folder. Select all the .c files in the folder except main (util.c, handyboard.c, spi.c, and dac.c) and hit OK.
- Right-click Header Files and select Add Files to Folder, and navigate to the BF_Handy_Board folder. Select all the .h files in the folder (util.h, handyboard.h, spi.h, and dac.h)
All the necessary files are now added to the project, and the coding can begin.
- Open the .c file that corresponds to your thread.
- We need header files in order to be able to use Handy Board functions. At the top of the file, include all 4 header files that were added to the project. In my case, this was:
#include "BF_Handy_Board\handyboard.h" #include "BF_Handy_Board\spi.h" #include "BF_Handy_Board\util.h" #include "BF_Handy_Board\dac.h"
- Inside the YourThreadName.c file, there is a function called YourThreadName_RunFunction. Inside this function, BEFORE the while loop, you need to call
hb_init();, and then inside the while loop will be your thread code.
If you choose to add more than one thread, you will need to manually initialize the threads that are not your boot thread. To do this, open the boot thread's .c file, and scroll down to the YourBootThread_InitFunction(). Inside here, you have to call VDK_CreateThread() like so:
VDK_CreateThread( kMySecondThread ); VDK_CreateThread( kMyThirdThread ); VDK_CreateThread( kMyFourthThread );
It seems that VDK just prepends "k" to your thread name, so try that first. If this fails, look inside VDK.h and search for "enum ThreadType" and look for your thread name in the enum.