Created by: Group 11 - Sean Hunter, Michael Wong, Thomas Zylstra
Description: This application note describes how to integrate a Flexipanel LinkMatik 2.0 Bluetooth Transceiver into a project using the Altera DE2 in order to enable audio data transfer between the board and a paired device. This application note applies to Quartus II v10.1, and uses the SOPC Builder tool. The software IDE used is the Nios II IDE Version 10.1sp1, Build 197.

NOTE: The demo project included with this application note is not fully working, but it should provide a solid starting point to any group hoping to use the LinkMatik 2.0 in their project. The demo project does perform some audio feedback to the target phone, but this feedback is currently a mere click. However, it should be noted that the PCM codec provided was successfully used with G11's Voice Manipulator in ECE492 w2013, with satisfactory audio quality.
Physical Connection: The LinkMatik 2.0 can be connected to the DE2 through the GPIO pins. In this appnote, we use GPIO_1(9 downto 0) to interface with the transceiver. The connection scheme is shown in the image below. Note that RESET remains unconnected. If reset functionality is desired, this should be given a pin.

Hardware Operation: The featured hardware in this appnote is the PCM codec (pcm_interface.vhd). This codec performs two functions: it takes an input audio data stream from a Nios II and serializes it, and it reads an incoming serial audio signal and converts it to a 16-bit integer that can be passed to the Nios II. The PCM standard is implemented for this audio transfer. When a call is ongoing, the LinkMatik 2.0 generates a 256kHz bit clock on the PCMC pin, shown on the first line in the timing diagram below. It also generates a synchronization signal that goes high on the rising edge of the bit clock and stays high for 7.5 cycles, then stays low for another 23.5 cycles. Thus there are 32 cycles of the bit clock between rising edges of the sync signal. 16-bit audio data is expected on the input and output lines (the third and fourth in the timing diagram) on the 16 successive falling edges of the bit clock following the rising edge of the synchronization signal.



Altera on-chip FIFOs are used in this demo project to facilitate data transfer between the Nios II and the PCM Codec. The FIFO that feeds integer samples to be transmitted is MM-WRITE, ST-SOURCE, so that integer values pushed to this FIFO are streamed to the codec. The FIFO that sends the deserialized samples to the Nios II is ST-SINK, MM-READ, so that the processor can read incoming values as needed. See the attached .sopc file for the needed configuration.



The LinkMatik 2.0 also implements an RS-232 compliant serial interface used to configure the transceiver. A UART should be included in the system to allow this communication. Through this interface, configuration commands can be sent to the transceiver, and status messages indicating the status of the link can be received. See the LinkMatik 2.0 Command Reference for more details on this operation.
Software Operation: Given the above hardware configuration, we should be able to simply read data from the incoming FIFO when a call is ongoing. Altera HAL API calls can be used to easily perform this task at a high level. This demo project then reads these values and simply writes them into the outgoing FIFO to be re-serialized. This results in operation in which audio incoming from a phone is routed back towards the target phone.
Files:
Instructions for Reproducing:
  1. Copy all files in this directory (except index.html) into the project folder
  2. Run scripts/launch_quartus.sh
  3. Create a new project; using the New Project Wizard, name the new project BluetoothDemo, add BluetoothDemo.vhd (the top level file), and configure for operation with the Altera DE2
  4. Open the SOPC Builder and open the file BT_demo.sopc
  5. Generate the system
  6. In Quartus, add all .vhd files except for niosII_system_inst.vhd
  7. Set BluetoothDemo.vhd as the top-level
  8. Import pin assignments, using pin_assignments/DE2_pin_assignments_all.csv
  9. Compile
  10. Run scripts/reconnect_jtag.sh and program the board with the generated BluetoothDemo.sof (a precompiled .sof is also present in compiled/Bluetooth.sof)
  11. Run scripts/launch_nios2_ide.sh
  12. Create a new MicroC OS project, setting the software directory and the niosII_system.ptf file
  13. Set the syslib properties to use sdram for all memory locations
  14. Copy the contents of software/main.c to the main C file of the newly created project
  15. Build the program and run
  16. Pair a cellphone with the project; it should appear as ECE492_VM
  17. Initiate a call with another phone (henceforth known as the target phone)
  18. Whatever is spoken into the target phone should be echoed back to the target phone
References:
  • TLV320AIC1110 PCM CODEC Datasheet, Texas Instruments
  • LinkMatik 2.0 Datasheet, FlexiPanel Ltd.
  • LinkMatik 2.0 Command Reference, FlexiPanel Ltd