Nano River Technologies April 2009

Size: px
Start display at page:

Download "Nano River Technologies April 2009"

Transcription

1 Miniboard Nano River Technologies April 2009 Rev: 1.4 (Apr 2009) Nano River Technolgies Page 1 of 67

2 Table of Contents 1. OVERVIEW WINDOWS GPIO TOOL FUNCTIONALITY PROJECT STRUCTURE DESIGN DESCRIPTION IIC COMMAND TOOL FUNCTIONALITY PROJECT STRUCTURE DESIGN DESCRIPTION WINDOWS IIC TOOL FUNCTIONALITY PROJECT STRUCTURE DESIGN DESCRIPTION WINDOWS EEPROM PROGRAMMER FUNCTIONALITY PROJECT STRUCTURE DESIGN DESCRIPTION IIC COMMAND TOOL (LINUX AND MACOS VERSIONS) FUNCTIONALITY PROJECT STRUCTURE DESIGN DESCRIPTION CONFIGURATION EXAMPLE (LINUX AND MACOS VERSIONS) FUNCTIONALITY PROJECT STRUCTURE DESIGN DESCRIPTION IIC CHECKER TOOL (MACOS XCODE COCOA) FUNCTIONALITY PROJECT STRUCTURE DESIGN DESCRIPTION Rev: 1.4 (Apr 2009) Nano River Technolgies Page 2 of 67

3 ABBREVIATIONS API EEPROM G++ GCC GPIO I2C IDE IIC IO NRT SPI USB Application Programming Interface Electrically Erasable Programmable Read Only Memory C++ compiler for Linux (part of GCC) GNU Compiler Collection General Purpose IO Inter-Integrated Circuit Integrated Design Environment Inter-Integrated Circuit (same as I2C) Input / Output Nano River Technologies Serial Peripheral Interface Universal Serial Bus Rev: 1.4 (Apr 2009) Nano River Technolgies Page 3 of 67

4 1. Overview This document provides information about the four application examples which come with the MiniBoard from Nano River Technologies. The application examples aim to show how to build your own C/C++ and Visual C++ applications and interface to the MiniBoard API. The four example applications described in the document are: Windows GPIO Tool IIC Command Tool Windows IIC Tool Windows EEPROM Programmer Two further examples have been included for Linux and MacOS applications. These run using GCC. IIC Command Tool (Linux and MacOS Versions) Configuration Example (Linux and MacOS Versions) One example is provided to show how to use MiniBoard from Xcode Cocoa, which is the current GUI IDE for MacOS. IIC Checker Tool (MacOS Xcode Cocoa) Rev: 1.4 (Apr 2009) Nano River Technolgies Page 4 of 67

5 2. Windows GPIO Tool This example application is a very simple Visual C++ GUI application showing how to interface to the general purpose IO (GPIO) pins. Slider Control Read Value 2.1. Functionality To use the application the user needs to select one of three slider control settings. One slider is provided for each bit. Each bit can be driven high as an output, driven low as an output or used as an input. Irrespective of whether the pin is configured as input or output the GPIO pin is then sampled and displayed as the read value. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 5 of 67

6 2.2. Project Structure In order to create such a Windows application in Visual C++, first start up a new project and select Window Form Application as the project type. This will create a standard Windows application. The project file structure will then look as follows. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 6 of 67

7 To this, one must add the MiniBoard class header file (miniboard_class.h) and MiniBoard class C++ file as follows. Windows Form Description MiniBoard Class Header File Application Top Level C++ File MiniBoard Class C++ File Remember to change the Common Language Runtime support to /clr. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 7 of 67

8 2.3. Design Description The main file which needs to be developed in a Windows GUI application is the Windows form application file (Form1.h). This can be built up graphically by dragging in elements of the.net development toolbox and/or by editing the Form1.h text file. The final Form1.h file can be found in the downloaded files for the GPIO Windows application available on the web-site. The file starts by linking to the MiniBoard class library header file: Nano River Technologies File: GPIOWindowsApplication (Form.h) Desciption: This is a simpe Windows application as a demonstration to show how to build up a simple Windows application and link to the GPIO functions in the Nano River Techologies MiniBoard. Revision: Version 1.0 #pragma once #include "../../common/miniboard_class.h" The file declares some global variables used in the application: Own Global variables here NANO_RESULT res; Returned result for calls to Nano River Tech functions MBc MB; The MiniBoard class library Int32 slider; Slider value Int32 bit; GPIO Bit number BOOL value; Read value of the GPIO bit bool connected; True if the MiniBoard is connected Rev: 1.4 (Apr 2009) Nano River Technolgies Page 8 of 67

9 Windows objects are defined: Define all the Windows objects here private: System::Windows::Forms::TrackBar^ trackbar_0; private: System::Windows::Forms::TrackBar^ trackbar_1; private: System::Windows::Forms::TrackBar^ trackbar_30; A function is defined during the form load. In this the connection to the MiniBoard is established by calling OpenDevice()in the MiniBoard class. Functions Nano_GPIOSetDirection and Nano_GPIOWrite are called to initialise all GPIOs as inputs. private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { A task called when the form is loaded. Here we open the USB link and initialise the MiniBoard. All GPIOs are initialised to all input. connected = ::MBc::OpenDevice(); if (!connected) this->label_50->visible = true; if (connected) { res = ::MBc::Nano_GPIOSetDirection(MB.mb_hDevice,0x ,0xFFFFFFFF); res = ::MBc::Nano_GPIOWrite(MB.mb_hDevice,0x ,0xFFFFFFFF); All inputs Values 0x0 Finally, a timer service routine is defined. Each time the timer ticks the control slider is checked to see if the GPIO needs to be updated as an output or if it needs to change to an input. In addition the GPIO is read and displayed. The process is repeated for all GPIOs. private: System::Void timer1_tick(system::object^ sender, System::EventArgs^ e) { Task to update all GPIOs each clock tick Bit 00 bit = 0; slider = this->trackbar_0->value; if (slider==0) res = ::MBc::Nano_GPIOSetSingleBitDirection(MB.mb_hDevice,bit,0); Input else if (slider==1) { res = ::MBc::Nano_GPIOSingleBitWrite(MB.mb_hDevice,bit,0); 0 res = ::MBc::Nano_GPIOSetSingleBitDirection(MB.mb_hDevice,bit,1); Output else if (slider==2) { res = ::MBc::Nano_GPIOSingleBitWrite(MB.mb_hDevice,bit,1); 1 res = ::MBc::Nano_GPIOSetSingleBitDirection(MB.mb_hDevice,bit,1); Output res = ::MBc::Nano_GPIOSingleBitRead(MB.mb_hDevice,bit,&value); this->textbox_0->text = Convert::ToString(value); Rev: 1.4 (Apr 2009) Nano River Technolgies Page 9 of 67

10 Some important links and includes are necessary in stdafx.h. This is best seen by viewing the file in the download from the web-site. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 10 of 67

11 3. IIC Command Tool This example application is a C/C++ console application showing how to call functions associated with the IIC such as IIC read, IIC write, IIC scan and various configuration commands. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 11 of 67

12 3.1. Functionality The application works by prompting the user for a new command. There are three main types of commands that are accepted. IIC Scan Command %cmd> s Here the program will scan all IIC addresses and report which devices are connected to the bus. IIC Write Command %cmd> w devid <Device ID> -sa <Start Address> -l <Length> -d <Data Sequence> Here the user specifies the device ID, internal start address, transfer length and the data sequence. An IIC write transaction is then initiated. IIC Read Command %cmd> r devid <Device ID> -sa <Start Address> -l <Length> Here the user specifies the device ID, internal start address and transfer length. An IIC read transaction is then initiated and returns the read data. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 12 of 67

13 3.2. Project Structure In order to create such a console application in Visual C++, first start up a new project and select Win32 Console Application as the project type. This will create a standard console application. The project file structure will then look as follows. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 13 of 67

14 To this, one must add the MiniBoard class header file (miniboard_class.h), the MiniBoard class C++ file (miniboard_class.cpp) and the libusb library (libusb.lib) as follows. MiniBoard Class Header File Main Program (Top) MiniBoard Class C++ File LibUSB library Rev: 1.4 (Apr 2009) Nano River Technolgies Page 14 of 67

15 3.3. Design Description The application is implemented using a single file (IICCommandToolApplication.cpp). The complete file and project can be downloaded from the web-site. The file starts by linking to the MiniBoard class library header file and the standard project header file: Nano River Technologies File: IICCommandToolApplication (IICCommandToolApplication.cpp) Desciption: This is a console application as a demonstration showing how to build up a simple application linking to the IIC functions for the Nano River Techologies MiniBoard. Revision: Version 1.0 #include "stdafx.h" #include "../../common/miniboard_class.h" using namespace std; The file declares some global variables used in the application: Global Variables BOOL d; Return result for opening the connection to MiniBoard NANO_RESULT e; Return result for all IIC commands for MiniBoard MBc MB; The MiniBoard class library BYTE InBuffer[256]; A buffer for receiving data from the IIC device BYTE OutBuffer[256]; A buffer for sending data to the IIC device DEV_LIST lst; Returned list of connected IIC devices char s[250]; Variable used to take the users input as a sting enum commandtype { NONE, READ, WRITE, SCAN, HELP ; The type of command commandtype command; The actual command long int deviceid = 0; The IIC Device ID long int startaddress = 0; The IIC start address long int length = 0; The IIC transfer length long int data[256]; An array storing the data to send int count = 0; Index into the data array int i; A variable used in scanning all possible IIC Device IDs bool datafound; True when the user has included data in the command Rev: 1.4 (Apr 2009) Nano River Technolgies Page 15 of 67

16 A help procedure is included to give the user instructions as to the correct syntax for commands: void help() Prints out a help banner to show the possible commands and formats etc. { printf (" \n"); printf ("+ Enter a command in the following format:\n"); printf (" \n"); printf ("+ IIC Device Scan... \n"); printf ("+ $cmd> s\n"); printf ("+ IIC Read... \n"); printf ("+ $cmd> r -devid <Device ID> -sa <Start Addr> -l <Length>\n"); printf ("+ Eg. $cmd> r -devid 50 -sa 00 -l 02\n"); printf ("+ IIC Write... \n"); printf ("+ $cmd> w -devid <Device ID> -sa <Start Addr> -l <Length> -d <Data Seq>\n"); printf ("+ Eg. $cmd> w -devid 50 -sa 00 -l 0A -d A 4F FF EF 11\n"); printf ("+ Help... \n"); printf ("+ $cmd> h\n"); printf (" \n\n"); The main program starts by printing out a startup banner and calling the user instructions: int _tmain(int argc, _TCHAR* argv[]) { The Tool header printf (" \n"); printf (" \n"); printf ("++ ++\n"); printf ("++ IIC Command Line Tool ++\n"); printf ("++ ++\n"); printf ("++ by Nano River Technologies ++\n"); printf ("++ support@nanorivertech.com ++\n"); printf ("++ ++\n"); printf (" \n"); printf (" \n\n\n"); help(); Rev: 1.4 (Apr 2009) Nano River Technolgies Page 16 of 67

17 The I2C interface is then initialised by calling the OpenDevice() in the MiniBoard class. Functions are then called to setup the I2C line rate. Initialise the Nano River Tech Board connected=mb.opendevice(); Open the MiniBoard if (!connected) { printf (" \n"); printf ("++ DEMONSTRATION MODE ONLY!\n"); printf (" \n\n"); if (connected) { e=mb.nano_iicsetfrequency(mb.mb_hdevice,nano_iic_freq_fast); Set the IIC frequency A main loop is included to prompt for user input: Main loop to take users commands while (1) { Prompt and get user input printf("\n"); printf ("$cmd> "); command = NONE; datafound = false; count = 0; gets(s); The remainder of the main loop and program then calls I2C functions based on the user s request. These are primarily I2C scan, I2C read and I2C write functions. The input needs to be parsed. The request along with the returned data is summarised and presented to the user on the screen. Now process the command char * pch; This is a variable used to store the next peice of the command Each peice is separated by spaces. char * last = ""; This is the last peice pch = strtok (s," "); Get the first peice of the command while (pch!= NULL) { if (strcmp( pch, "r" )==0) If a read is found command = READ; if (strcmp( pch, "w" )==0) If a write is found command = WRITE; if (strcmp( pch, "s" )==0) If an IIC scan is requested command = SCAN; if (strcmp( pch, "h" )==0) If a help is requested command = HELP; Rev: 1.4 (Apr 2009) Nano River Technolgies Page 17 of 67

18 if (strcmp( last, "-devid" )==0) { Check for DEVID flag as the last peice deviceid = strtol(pch,null,16); Store the DEVID datafound=false; if (strcmp( last, "-sa" )==0) { Check for start address flag as the last peice startaddress = strtol(pch,null,16); Store the start address datafound=false; if (strcmp( last, "-l" )==0) { Check for the length flag as the last peice length = strtol(pch,null,16); Store the length datafound=false; if (datafound) { Check if we are accepting data data[count] = strtol(pch,null,16); Store the data count++; Increment data index if (strcmp( pch, "-d" )==0) Flag that we are taking data datafound = true; last = pch; pch = strtok (NULL, " "); Get next peice of the string Zero un-spcified data for (i=count; i<length; i++) data[i] = 0; Act on the required IIC command switch ( command ) { No command case NONE : printf("\n"); printf("incorrect command type!\n\n"); help(); break; Help command case HELP : help(); break; Read command case READ : printf("\n"); printf(" Read...\n"); if (connected) e=mb.nano_iicread(mb.mb_hdevice,byte(deviceid),2,word(startaddress), WORD(length),InBuffer); The Nano River Tech IIC Read command if (e==nano_success) { printf(" Device ID : %02X\n",deviceID); printf(" Start Address : %04X\n",startAddress); printf(" Length : %04X\n",length); printf(" Data :"); for (i=0; i<length; i++) { printf(" %02X",InBuffer[i]); if (((i+1)%16)==0) printf("\n "); printf("\n"); printf(" Successfull Read!\n"); Display the data Rev: 1.4 (Apr 2009) Nano River Technolgies Page 18 of 67

19 else { printf("\n"); printf(" Error on Read!\n"); break; Write command case WRITE: printf("\n"); printf(" Write...\n"); printf(" Device ID : %02X\n",deviceID); printf(" Start Address : %04X\n",startAddress); printf(" Length : %04X\n",length); printf(" Data :"); for (i=0; i<length; i++) { OutBuffer[i] = BYTE(data[i]); printf(" %02X",data[i]); if (((i+1)%16)==0) printf("\n "); if (connected) Prepare the data e=mb.nano_iicwrite(mb.mb_hdevice,byte(deviceid),2,word(startaddress), WORD(length),OutBuffer); The Nano River Tech IIC Write command printf("\n"); if (e==nano_success) printf(" Successfull Write!\n"); else printf(" Error on Write!\n"); break; Scan command case SCAN : printf("\n"); printf(" Scan...\n\n"); if (connected) e=mb.nano_iicscanconnecteddevices(mb.mb_hdevice,&lst); The Nano River Tech IIC Scan command printf(" IIC Devices Connected... "); for (i=0;i<128;i++) { if (lst.list[i]) {printf("%02x ",i); printf("\n"); break; return 0; Some important links and includes are necessary in stdafx.h. This is best seen by viewing the file in the download from the web-site. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 19 of 67

20 4. Windows IIC Tool This example application is a windows GUI application in Visual C++ used to illustrate how to access I2C functions. Scan Button Read Button Write Button Information Window Rev: 1.4 (Apr 2009) Nano River Technolgies Page 20 of 67

21 4.1. Functionality In this application the user can request one of three types of IIC accesses. IIC Scan In this case the user need only press the Scan Button. The list of connected devices is then returned in the information window. IIC Read For a read, the user needs to enter the device ID, start address for the transfer and the transfer length. When the user presses the Read Button an IIC read transfer is initiated. A summary of the transfer is sent to the information window, including the returned data from the device. IIC Write For a write, the user needs to enter the device ID, start address for the transfer, transfer length and the data sequence to be transferred. When the user presses the Write Button the IIC write transfer is made and a summary of the transfer is sent to the information window. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 21 of 67

22 4.2. Project Structure In order to create such a Windows application in Visual C++, first start up a new project and select Window Form Application as the project type. This will create a standard Windows application. The project file structure will then look as follows. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 22 of 67

23 To this, one must add the MiniBoard class header file (miniboard_class.h) and MiniBoard class C++ file as follows. Windows Form Description MiniBoard Class Header File Application Top Level C++ File MiniBoard Class C++ File Remember to change the Common Language Runtime support to /clr. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 23 of 67

24 4.3. Design Description The main file which needs to be developed in a Windows GUI application is the Windows form application file (Form1.h). This can be built up graphically by dragging in elements of the.net development toolbox and/or by editing the Form1.h text file. The final Form1.h file can be found in the downloaded files for the IIC Windows application available on the web-site. The file starts by linking to the MiniBoard class library header file: Nano River Technologies File: IICWindowsApplication (Form.h) Desciption: This is a simpe Windows application as a demonstration to show how to build up a simple Windows application and link to the IIC functions in the Nano River Techologies MiniBoard. Revision: Version 1.0 #pragma once #include "../../common/miniboard_class.h" The file declares some global variables used in the application: Own Global variables here NANO_RESULT res; Returned result for calls to Nano River Tech functions DEV_LIST lst; Returned list of connected IIC devices Int32 i; General purpose loop variable BYTE SlaveAddress; The IIC slave address WORD StartAddress; The start address for the particular device WORD BufferLength; Length of the IIC transfer BYTE InBuffer[256]; A buffer for receiving data from the IIC device BYTE OutBuffer[256]; A buffer for sending data to the IIC device MBc MB; The MiniBoard class library bool connected; True if the MiniBoard is connected Rev: 1.4 (Apr 2009) Nano River Technolgies Page 24 of 67

25 Windows objects are defined: Define all the Windows objects here private: System::Windows::Forms::Label^ label_1; private: System::Windows::Forms::Label^ label_2; private: System::Windows::Forms::Label^ label_3; private: System::Windows::Forms::Button^ button_1; private: System::Windows::Forms::Button^ button_2; private: System::Windows::Forms::Button^ button_3; private: System::Windows::Forms::TextBox^ textbox_1; private: System::Windows::Forms::TextBox^ textbox_2; private: System::Windows::Forms::TextBox^ textbox_3; private: System::Windows::Forms::TextBox^ textbox_4; private: System::Windows::Forms::RichTextBox^ richtextbox_1; We then define some managed variables: Managed variables String ^s1; A local string variable used for RichTechBox output String ^s2; 2nd local string variable used for RichTechBox output String ^s3; 3rd local string variable used for RichTechBox output String ^Data; A string used for parsing the data input textbox A function is defined during the form load. In this the connection to the MiniBoard is established by calling OpenDevice() in the MiniBoard class. private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { A task called when the form is loaded. Here we just open the USB link and initialise the MiniBoard. connected = ::MBc::OpenDevice(); if (!connected) this->label_0->visible = true; for (i=0;i<128;i++) lst.list[i] = false; lst.list[0x50] = true; For the demo we show 0x50 as connected Rev: 1.4 (Apr 2009) Nano River Technolgies Page 25 of 67

26 A function is defined for when the user presses the Scan Button. When this occurs, the scan function is called from the MiniBoard class. The function returns a list containing the I2C addresses of connected devices. The function displays the result in the information window. private: System::Void button_1_click(system::object^ sender, System::EventArgs^ e) { This is the task called when we press the button for scanning. Here we just call the IIC scan task and display the result. s1= "Scanning...\n"; s2= " Device\(s\) found:"; s3= " No Device Connected"; bool found; found = false; if (connected) res = ::MBc::Nano_IICScanConnectedDevices(MB.mb_hDevice,&lst); Call the IIC scan task here for (i=0;i<128;i++) { if (lst.list[i]) { found=true; s2 = System::String::Concat( s2," 0x"); s2 = System::String::Concat( s2,i.tostring("x2")); if (found) { s1 = System::String::Concat( s1,s2); else { s1 = System::String::Concat( s1,s3); this->richtextbox_1->text = s1; Rev: 1.4 (Apr 2009) Nano River Technolgies Page 26 of 67

27 A function is defined for when the user presses the Read Button. When this occurs, the device ID, start address and transfer length are taken from the content of the corresponding textboxes. A call is made to the I2C read function from the MiniBoard class. The function returns a buffer of data. A summary of the transfer is presented to the user including the read data in the information window. private: System::Void button_2_click(system::object^ sender, System::EventArgs^ e) { This is a function called when we press the IIC read button. The function calls the IIC read task for the MiniBoard and displays the result. Parameters are taken from the other TextBoxes. if (connected) { res = ::MBc::Nano_IICSetFrequency(MB.mb_hDevice,NANO_IIC_FREQ_FAST); Setup the clock speed SlaveAddress = Int32::Parse(this->textBox_1-> Text,System::Globalization::NumberStyles::HexNumber); Get slave address from TextBox StartAddress = Int32::Parse(this->textBox_3-> Text,System::Globalization::NumberStyles::HexNumber); Get start address from TextBox BufferLength = Int32::Parse(this->textBox_5-> Text,System::Globalization::NumberStyles::HexNumber); Get buffer length from TextBox bool error; error = false; s1= "Reading"; s2= " "; s3= " Error on read"; s1 = System::String::Concat( s1," (Device ID 0x"); s1 = System::String::Concat( s1,slaveaddress.tostring("x2")); s1 = System::String::Concat( s1,") (Start Addr 0x"); s1 = System::String::Concat( s1,startaddress.tostring("x4")); s1 = System::String::Concat( s1,")...\n\n"); if (connected) res = ::MBc::Nano_IICRead(MB.mb_hDevice,SlaveAddress,2,StartAddress, BufferLength,InBuffer); Call the IIC read task here if (res!=nano_success) error = true; for (i=0;i<bufferlength;i++) { Print the resultant buffer s2 = System::String::Concat( s2," 0x"); s2 = System::String::Concat( s2,inbuffer[i].tostring("x2")); if (((i+1)%16)==0) s2 = System::String::Concat( s2,"\n "); if (error) { s1 = System::String::Concat( s1,s3); else { s1 = System::String::Concat( s1,s2); this->richtextbox_1->text = s1; Rev: 1.4 (Apr 2009) Nano River Technolgies Page 27 of 67

28 A function is defined for when the user presses the Write Button. When this occurs, the device ID, start address, transfer length and data sequence are taken from the content of the corresponding textboxes. A call is made to the I2C write function from the MiniBoard class. When the transfer is complete a summary of the transfer is presented to the user in the information window. If the transfer length exceeds the data sequence entered then 0x00 is written. private: System::Void button_3_click(system::object^ sender, System::EventArgs^ e) { This is a function called when we press the IIC write button. The function calls the IIC write task for the MiniBoard and displays the result. Parameters are taken from the other TextBoxes. if (connected) { res = ::MBc::Nano_IICSetFrequency(MB.mb_hDevice,NANO_IIC_FREQ_FAST); Setup the clock speed SlaveAddress = Int32::Parse(this->textBox_2-> Text,System::Globalization::NumberStyles::HexNumber); Get slave address from TextBox StartAddress = Int32::Parse(this->textBox_4-> Text,System::Globalization::NumberStyles::HexNumber); Get start address from TextBox BufferLength = Int32::Parse(this->textBox_6-> Text,System::Globalization::NumberStyles::HexNumber); Get buffer length from TextBox Data = this->textbox_7->text; array<string^>^ splitdata = Data->Split(' '); Do string splitting to get the individual data entries. Expect a space between bool error; error = false; s1= "Writing"; s2= " "; s3= " Error on write"; s1 = System::String::Concat( s1," (Device ID 0x"); s1 = System::String::Concat( s1,slaveaddress.tostring("x2")); s1 = System::String::Concat( s1,") (Start Addr 0x"); s1 = System::String::Concat( s1,startaddress.tostring("x4")); s1 = System::String::Concat( s1,")...\n\n"); for (i=0; i<256; i++) { OutBuffer[i]=0; Default data is 0 unless specified for (i=0; i<splitdata->length; i++) if (i<bufferlength) Fill output buffer with data OutBuffer[i]=Convert::ToInt32(splitData[i],16); for (i=0;i<bufferlength;i++) { Print Buffer s2 = System::String::Concat( s2," 0x"); s2 = System::String::Concat( s2,outbuffer[i].tostring("x2")); if (((i+1)%16)==0) s2 = System::String::Concat( s2,"\n "); if (connected) res = ::MBc::Nano_IICWrite(MB.mb_hDevice,SlaveAddress,2,StartAddress, BufferLength,OutBuffer); Call the IIC write task here if (res!=nano_success) error = true; if (error) { s1 = System::String::Concat( s1,s3); else { s1 = System::String::Concat( s1,s2); this->richtextbox_1->text = s1; Rev: 1.4 (Apr 2009) Nano River Technolgies Page 28 of 67

29 Some important links and includes are necessary in stdafx.h. This is best seen by viewing the file in the download from the web-site. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 29 of 67

30 5. Windows EEPROM Programmer This example application example is a simple programmer for either I2C or SPI EEPROMs. The application is intended as a slightly more complex example of how to interface to both I2C and SPI interfaces in a real-life example. I2C/SPI select I2C Configuration SPI Configuration File IO Image editing Image Window Information Window Rev: 1.4 (Apr 2009) Nano River Technolgies Page 30 of 67

31 5.1. Functionality To use this application the user needs to select between I2C and SPI style EEPROMs. This is achieved by using the I2C/SPI pull-down menu. For I2C EEPROMs, the user must then continue to configure the chip size, page size, device ID, clock speed and write time by the various pull-down menus and text boxes in the I2C configuration. Similarly for SPI EEPROMs, the user needs to configure the chip size, page size, clock rate, clock polarity, clock phase and write time from the SPI configuration. The current image in the programmer memory is displayed in the image window. One can scroll through this image to see all locations. To read from file one should specify the file name and press the Read File button. To save an image to file one should specify the file name and press the Write File button. To edit a single location of the programmer image then specify the address and new data then press the Update button in the image editing. For random image import or to have 0xFF in all locations then press the Random Fill or FF Fill buttons. When the image is ready for programming one should press the Program button. The programming should immediately be checked by pressing the Verify button. An image can be read into the programmer s memory from chip using the Read button. Success or otherwise of any of the operations is displayed in the information window. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 31 of 67

32 5.2. Project Structure In order to create such a Windows application in Visual C++, first start up a new project and select Window Form Application as the project type. This will create a standard Windows application. The project file structure will then look as follows. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 32 of 67

33 To this, one must add the MiniBoard class header file (miniboard_class.h) and MiniBoard class C++ file as follows. Windows Form Description MiniBoard Class Header File Application Top Level C++ File MiniBoard Class C++ File Remember to change the Common Language Runtime support to /clr. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 33 of 67

34 5.3. Design Description The main file which needs to be developed in a Windows GUI application is the Windows form application file (Form1.h). This can be built up graphically by dragging in elements of the.net development toolbox and/or by editing the Form1.h text file. The final Form1.h file can be found in the downloaded files for the EEPROM Programmer application available on the web-site. The file starts by linking to the MiniBoard class library header file: Nano River Technologies File: EEPROMProgrammerApplication (Form.h) Desciption: This is a simple EEPROM programmer working for IIC or SPI style EEPROMs. The programmer is made as an example of how to build a Windows style application using IIC and SPI commands and the Nano River Technologies MiniBoard. Revision: Version 1.0 #pragma once #include "../../common/miniboard_class.h" The file declares some global variables used in the application: Own Global variables here const Int32 MEMORYMAX = 65536; Maximum size of the memory array Int32 no_screens; Number of screens of data to be displayed Int32 chip_size; The actual chip size Int32 page_size; The actial chip page size Int32 page_no; Page number Int32 iic_write_time; Chip write time (for IIC devices) Int32 spi_write_time; Chip write time (for SPI devices) NANO_RESULT res; Returned result for calls to Nano River Tech functions Int32 i,j; Loop variables BYTE SlaveAddress; IIC slave address (Device ID) WORD StartAddress; IIC transaction start address WORD BufferLength; IIC buffer length BYTE iic_frequency; IIC serial bit rate BYTE InBuffer[256]; IIC input buffer (data from IIC device) BYTE OutBuffer[256]; IIC output buffer (data for IIC device) Rev: 1.4 (Apr 2009) Nano River Technolgies Page 34 of 67

35 BYTE spi_frequency; SPI serial clock rate BYTE spi_polarity; SPI polarity setting BYTE spi_phase; SPI phase setting BYTE in_buffer[256]; SPI input buffer (data from SPI device) BYTE out_buffer[256]; SPI output buffer (data for SPI device) BYTE memory[memorymax]; Storage to hold data to be programmed BYTE verify_memory[memorymax]; Storage to hold data that was read MBc MB; The MiniBoard class library bool connected; True if the MiniBoard is connected Windows objects are defined: private: System::Windows::Forms::Label^ label_000; private: System::Windows::Forms::Label^ label_001; private: System::Windows::Forms::Label^ label_002; private: System::Windows::Forms::ComboBox^ combobox_000; private: System::Windows::Forms::ComboBox^ combobox_001; private: System::Windows::Forms::ComboBox^ combobox_002; private: System::Windows::Forms::TextBox^ textbox_000; private: System::Windows::Forms::TextBox^ textbox_001; private: System::Windows::Forms::TextBox^ textbox_002; private: System::Windows::Forms::Button^ button_000; private: System::Windows::Forms::Button^ button_001; private: System::Windows::Forms::Button^ button_002; private: System::Windows::Forms::RichTextBox^ richtextbox_000; private: System::Windows::Forms::RichTextBox^ richtextbox_001; private: System::Windows::Forms::RichTextBox^ richtextbox_002; private: System::Windows::Forms::VScrollBar^ vscrollbar_000; Some managed variables are then declared: Managed variables String ^s1; A local string variable used for RichTechBox output String ^s2; 2nd local string variable used for RichTechBox output String ^s3; 3rd local string variable used for RichTechBox output String ^Data; A string used for parsing the data input textbox Rev: 1.4 (Apr 2009) Nano River Technolgies Page 35 of 67

36 A function is defined to display the current programmer contents. This is displayed in the image window. The EEPROM image is broken into screens and displayed one screen at a time. The scroll bar changes to the next screen of image. private: System::Void ScreenUpdate() { A function to display the current screen of EEPROM data. Manages to show only the current screen based on the virtical slider. Int32 i,j; j = this->vscrollbar_000->value; s2=""; s2 = System::String::Concat( s2,j.tostring("x6")); this->richtextbox_001->text = s2; s2 = ""; for (i=0; i<256; i++) { if ((i%16)==0) { s2= System::String::Concat( s2," "); s2 = System::String::Concat( s2,(256*j+i).tostring("x7")); s2= System::String::Concat( s2," "); s2 = System::String::Concat( s2," "); s2 = System::String::Concat( s2,memory[256*j+i].tostring("x2")); if (((i+1)%16)==0) { s2= System::String::Concat( s2,"\n"); this->vscrollbar_000->maximum = no_screens+8; this->richtextbox_001->text = s2; A function is defined during the form load. In this connection to the MiniBoard is established by calling the OpenDevice() in the MiniBoard class. The function also initialises the programmer contents and also the global variables. Finally a call is made to display the first screen of the image. private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { A task called when the form is loaded. Here we open the USB link and initialise the MiniBoard. Also initialise all the global varaibles. connected = ::MBc::OpenDevice(); Open the device if (!connected) this->label_300->visible = true; for (i=0; i<memorymax; i++) memory[i] = rand()&0xff; Randomise the image no_screens = 64; Default values are set below... page_size = 64; page_no = 0; chip_size = no_screens * 256; iic_frequency=nano_iic_freq_fast; spi_frequency=nano_spi_freq_400khz; iic_write_time = 5; spi_write_time = 5; ScreenUpdate(); Screen update Rev: 1.4 (Apr 2009) Nano River Technolgies Page 36 of 67

37 This function updates the image window when the user clicks on the vertical scroll bar. private: System::Void vscrollbar_000_scroll(system::object^ sender, System::Windows::Forms::ScrollEventArgs^ e) { On a virtical slider movement update the screen ScreenUpdate(); These two functions re-calculate chip size and number of screens to display of the image in the case there has been an update to the chip size pull-down menu. One function is provided for I2C and one for the SPI case. private: System::Void combobox_001_selectedindexchanged(system::object^ sender, System::EventArgs^ e) { Update the chip size when IIC EEPROM is selected if (this->combobox_000->text=="iic") { page_no = 0; if (this->combobox_001->text=="512kbit") no_screens = 256; if (this->combobox_001->text=="256kbit") no_screens = 128; if (this->combobox_001->text=="128kbit") no_screens = 64; if (this->combobox_001->text=="64kbit") no_screens = 32; if (this->combobox_001->text=="32kbit") no_screens = 16; if (this->combobox_001->text=="16kbit") no_screens = 8; if (this->combobox_001->text=="8kbit") no_screens = 4; if (this->combobox_001->text=="4kbit") no_screens = 2; if (this->combobox_001->text=="2kbit") no_screens = 1; this->vscrollbar_000->value=0; chip_size = no_screens * 256; private: System::Void combobox_005_selectedindexchanged(system::object^ sender, System::EventArgs^ e) { Update the chip size when SPI EEPROM is selected if (this->combobox_000->text=="spi") { page_no = 0; if (this->combobox_005->text=="512kbit") no_screens = 256; if (this->combobox_005->text=="256kbit") no_screens = 128; if (this->combobox_005->text=="128kbit") no_screens = 64; if (this->combobox_005->text=="64kbit") no_screens = 32; if (this->combobox_005->text=="32kbit") no_screens = 16; if (this->combobox_005->text=="16kbit") no_screens = 8; if (this->combobox_005->text=="8kbit") no_screens = 4; if (this->combobox_005->text=="4kbit") no_screens = 2; if (this->combobox_005->text=="2kbit") no_screens = 1; this->vscrollbar_000->value=0; chip_size = no_screens * 256; Rev: 1.4 (Apr 2009) Nano River Technolgies Page 37 of 67

38 These two functions re-calculate page size in the case there has been an update to the page size pull-down menu. One function is provided for I2C and one for the SPI case. private: System::Void combobox_002_selectedindexchanged(system::object^ sender, System::EventArgs^ e) { Update the page size variable when IIC is selected if (this->combobox_000->text=="iic") { if (this->combobox_002->text=="4byte") page_size = 4; if (this->combobox_002->text=="8byte") page_size = 8; if (this->combobox_002->text=="16byte") page_size = 16; if (this->combobox_002->text=="32byte") page_size = 32; if (this->combobox_002->text=="64byte") page_size = 64; if (this->combobox_002->text=="128byte") page_size = 128; if (this->combobox_002->text=="256kbit") page_size = 256; private: System::Void combobox_006_selectedindexchanged(system::object^ sender, System::EventArgs^ e) { Update the page size variable when SPI is selected if (this->combobox_000->text=="spi") { if (this->combobox_006->text=="4byte") page_size = 4; if (this->combobox_006->text=="8byte") page_size = 8; if (this->combobox_006->text=="16byte") page_size = 16; if (this->combobox_006->text=="32byte") page_size = 32; if (this->combobox_006->text=="64byte") page_size = 64; if (this->combobox_006->text=="128byte") page_size = 128; if (this->combobox_006->text=="256kbit") page_size = 256; These two functions re-calculate clock frequency in the case there has been an update to the clock frequency pull-down menu. One function is provided for I2C and one for the SPI case. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 38 of 67

39 private: System::Void combobox_003_selectedindexchanged(system::object^ sender, System::EventArgs^ e) { Update the clock frequency for IIC EEPROMs if (this->combobox_000->text=="iic") { if (this->combobox_003->text=="10khz") iic_frequency=nano_iic_freq_10khz; if (this->combobox_003->text=="20khz") iic_frequency=nano_iic_freq_20khz; if (this->combobox_003->text=="40khz") iic_frequency=nano_iic_freq_40khz; if (this->combobox_003->text=="60khz") iic_frequency=nano_iic_freq_60khz; if (this->combobox_003->text=="80khz") iic_frequency=nano_iic_freq_80khz; if (this->combobox_003->text=="std") iic_frequency=nano_iic_freq_std; if (this->combobox_003->text=="200khz") iic_frequency=nano_iic_freq_200khz; if (this->combobox_003->text=="fast") iic_frequency=nano_iic_freq_fast; private: System::Void combobox_007_selectedindexchanged(system::object^ sender, System::EventArgs^ e) { Update the clock frequency for SPI EEPROMs if (this->combobox_000->text=="spi") { if (this->combobox_007->text=="10khz") spi_frequency=nano_spi_freq_10khz; if (this->combobox_007->text=="20khz") spi_frequency=nano_spi_freq_20khz; if (this->combobox_007->text=="40khz") spi_frequency=nano_spi_freq_40khz; if (this->combobox_007->text=="60khz") spi_frequency=nano_spi_freq_60khz; if (this->combobox_007->text=="80khz") spi_frequency=nano_spi_freq_80khz; if (this->combobox_007->text=="100khz") spi_frequency=nano_spi_freq_100khz; if (this->combobox_007->text=="200khz") spi_frequency=nano_spi_freq_200khz; if (this->combobox_007->text=="400khz") spi_frequency=nano_spi_freq_400khz; These two functions re-calculate chip write time in the case there has been an update to the write time pull-down menu. One function is provided for I2C and one for the SPI case. private: System::Void combobox_004_selectedindexchanged(system::object^ sender, System::EventArgs^ e) { Update the chip write time for IIC EEPROMs if (this->combobox_000->text=="iic") { if (this->combobox_004->text=="5ms") iic_write_time=5; if (this->combobox_004->text=="10ms") iic_write_time=10; if (this->combobox_004->text=="15ms") iic_write_time=15; if (this->combobox_004->text=="20ms") iic_write_time=20; if (this->combobox_004->text=="50ms") iic_write_time=50; private: System::Void combobox_010_selectedindexchanged(system::object^ sender, System::EventArgs^ e) { Update the chip write time for SPI EEPROMs if (this->combobox_000->text=="iic") { if (this->combobox_010->text=="5ms") spi_write_time=5; if (this->combobox_010->text=="10ms") spi_write_time=10; if (this->combobox_010->text=="15ms") spi_write_time=15; if (this->combobox_010->text=="20ms") spi_write_time=20; if (this->combobox_010->text=="50ms") spi_write_time=50; Rev: 1.4 (Apr 2009) Nano River Technolgies Page 39 of 67

40 These two functions re-calculate the SPI clock polarity and phase in the case there was a change to the polarity or phase pull-down menu respectively. private: System::Void combobox_008_selectedindexchanged(system::object^ sender, System::EventArgs^ e) { Update the polarity setting for SPI EEPROMs if (this->combobox_000->text=="spi") { if (this->combobox_008->text=="0") spi_polarity=0; if (this->combobox_008->text=="1") spi_polarity=1; private: System::Void combobox_009_selectedindexchanged(system::object^ sender, System::EventArgs^ e) { Update the phase setting for SPI EEPROMs if (this->combobox_000->text=="spi") { if (this->combobox_009->text=="0") spi_phase=0; if (this->combobox_009->text=="1") spi_phase=1; This function is provided for when there is a click on the Update button. In this case the address and new data is used to update one locate in the programmer memory. A screen update is made to make sure the user sees this too. private: System::Void button_002_click(system::object^ sender, System::EventArgs^ e) { This function is for the Update button click detection. When the button is clicked then the corresponding memory location is updated. Int32 updateaddress; Int32 updatedata; updateaddress = 0xFFFFFF & Int32::Parse(this-> textbox_003->text,system::globalization::numberstyles::hexnumber); updatedata = 0xFF & Int32::Parse(this-> textbox_004->text,system::globalization::numberstyles::hexnumber); memory[updateaddress] = updatedata; ScreenUpdate(); s2="updated location "; s2 = System::String::Concat( s2,updateaddress.tostring("x4")); s2 = System::String::Concat( s2," with "); s2 = System::String::Concat( s2,updatedata.tostring("x2")); s2 = System::String::Concat( s2,"."); this->richtextbox_002->text = s2; Rev: 1.4 (Apr 2009) Nano River Technolgies Page 40 of 67

41 This function is provided for writing the image to the physical device. The function handles both I2C and SPI EEPROM types. The write time delay is allowed for between pages. private: System::Void button_003_click(system::object^ sender, System::EventArgs^ e) { Inplements the click activity for the WRITE button. Implements both IIC and SPI behaviour. bool error; error = false; if (this->combobox_000->text=="iic") { IIC CASE if (connected) { res = ::MBc::Nano_IICSetFrequency(MB.mb_hDevice,iic_frequency); SlaveAddress = Int32::Parse(this->textBox_000-> Text,System::Globalization::NumberStyles::HexNumber); Get Device ID StartAddress = 0x00; BufferLength = page_size; Set page size Get frequency for (j=0; j<(chip_size/page_size); j++) { Loop page at a time for (i=0; i<bufferlength; i++) { OutBuffer[i]=memory[i+j*page_size]; if (connected) res = ::MBc::Nano_IICWrite(MB.mb_hDevice,SlaveAddress,2,StartAddress,BufferLength, OutBuffer); IIC Write command if (res!=nano_success) error = true; Sleep(iic_write_time); Delay to allow for the chip write time StartAddress = StartAddress + page_size; if (error==true) s2="error during IIC write"; else s2="device IIC write"; this->richtextbox_002->text = s2; if (this->combobox_000->text=="spi") { SPI CASE if (connected) { res=::mbc::nano_spisetclockconfig(mb.mb_hdevice,spi_polarity,spi_phase); Set the SPI polarity/phase res=::mbc::nano_spisetfrequency(mb.mb_hdevice,spi_frequency); Set SPI frequency for (j=0; j<(chip_size/page_size); j++) { Loop page at a time Write Enable out_buffer[0] = 0x06; Opcode res=::mbc::nano_spireadwrite(mb.mb_hdevice, 0x01, in_buffer, out_buffer, 0x01); if (res!=nano_success) error = true; Sleep(1); Delay to make sure the write enable occurs Write out_buffer[0] = 0x02; Opcode for a WRITE out_buffer[1] = 0xFF & ((j*page_size)>>8); MSB Address out_buffer[2] = 0xFF & (j*page_size); LSB Address for (i=0; i<page_size; i++) out_buffer[i+3] = memory[i+j*page_size]; if (connected) res=::mbc::nano_spireadwrite(mb.mb_hdevice, NANO_SPI_CHIPSELECT_CS, in_buffer, out_buffer, page_size+3); if (res!=nano_success) error = true; Sleep(spi_write_time); if (error==true) s2="error during SPI write"; else s2="device SPI write"; this->richtextbox_002->text = s2; Delay to allow for the chip write time Rev: 1.4 (Apr 2009) Nano River Technolgies Page 41 of 67

42 This function is provided for reading the physical device into the programmer image. private: System::Void button_005_click(system::object^ sender, System::EventArgs^ e) { Inplements the click activity for the READ button. Implements both IIC and SPI behaviour. bool error; error = false; if (this->combobox_000->text=="iic") { IIC CASE if (connected) { res = ::MBc::Nano_IICSetFrequency(MB.mb_hDevice,iic_frequency); Set frequency SlaveAddress = Int32::Parse(this-> textbox_000->text,system::globalization::numberstyles::hexnumber); Get Device ID StartAddress = 0x00; BufferLength = page_size; Set page size for (j=0; j<(chip_size/page_size); j++) { if (connected) res = ::MBc::Nano_IICRead(MB.mb_hDevice,SlaveAddress,2,StartAddress, BufferLength,InBuffer); IIC Read if (res!=nano_success) error = true; for (i=0; i<bufferlength; i++) memory[i+j*page_size] = InBuffer[i]; StartAddress = StartAddress + page_size; if (error==true) s2="error during IIC read"; else s2="device IIC read"; this->richtextbox_002->text = s2; ScreenUpdate(); Update the screen if (this->combobox_000->text=="spi") { SPI CASE if (connected) { res=::mbc::nano_spisetclockconfig(mb.mb_hdevice,spi_polarity,spi_phase); Set the SPI polarity/phase res=::mbc::nano_spisetfrequency(mb.mb_hdevice,spi_frequency); Set the SPI frequency for (j=0; j<(chip_size/page_size); j++) { out_buffer[0] = 0x03; Opcode for a READ out_buffer[1] = 0xFF & ((j*page_size)>>8); MSB Address out_buffer[2] = 0xFF & (j*page_size); LSB Address if (connected) res=::mbc::nano_spireadwrite(mb.mb_hdevice, NANO_SPI_CHIPSELECT_CS, in_buffer, out_buffer, page_size+3); if (res!=nano_success) error = true; for (i=0; i<page_size; i++) memory[i+j*page_size] = in_buffer[i+3]; if (error==true) s2="error during SPI read"; else s2="device SPI read"; this->richtextbox_002->text = s2; ScreenUpdate(); SPI read Rev: 1.4 (Apr 2009) Nano River Technolgies Page 42 of 67

43 This function is provided for verifying the image that got written is the same as the programmer image. private: System::Void button_004_click(system::object^ sender, System::EventArgs^ e) { Inplements the click activity for the VERIFY button. Implements both IIC and SPI behaviour. bool error; bool match; error = false; match =true; if (this->combobox_000->text=="iic") { IIC CASE if (connected) { res = ::MBc::Nano_IICSetFrequency(MB.mb_hDevice,iic_frequency); Set frequency SlaveAddress = Int32::Parse(this->textBox_000->Text, System::Globalization::NumberStyles::HexNumber); Get Device ID StartAddress = 0x00; BufferLength = page_size; for (j=0; j<(chip_size/page_size); j++) { if (connected) res = ::MBc::Nano_IICRead(MB.mb_hDevice,SlaveAddress,2,StartAddress, BufferLength,InBuffer); IIC read if (res!=nano_success) error = true; for (i=0; i<bufferlength; i++) verify_memory[i+j*page_size] = InBuffer[i]; read into a verification array StartAddress = StartAddress + page_size; if (this->combobox_000->text=="spi") { SPI CASE if (connected) { res=::mbc::nano_spisetclockconfig(mb.mb_hdevice,spi_polarity,spi_phase); Set the SPI polarity/phase res=::mbc::nano_spisetfrequency(mb.mb_hdevice,spi_frequency); Set the SPI frequency for (j=0; j<(chip_size/page_size); j++) { out_buffer[0] = 0x03; Opcode for a READ out_buffer[1] = 0xFF & ((j*page_size)>>8); MSB Address out_buffer[2] = 0xFF & (j*page_size); LSB Address if (connected) res=::mbc::nano_spireadwrite(mb.mb_hdevice, NANO_SPI_CHIPSELECT_CS, in_buffer, out_buffer, page_size+3); if (res!=nano_success) error = true; for (i=0; i<page_size; i++) verify_memory[i+j*page_size] = in_buffer[i+3]; for (j=0; j<chip_size; j++) if (memory[j]!= verify_memory[j]) match = false; if (error==true) s2="error during device read"; else if (match!=true) s2="error during programming"; else s2="veification completed OK"; this->richtextbox_002->text = s2; Do the element by element check read into a verification array Rev: 1.4 (Apr 2009) Nano River Technolgies Page 43 of 67

44 To follow is a function to read in an intel hex format file, parse it and then use this as the programmer image. private: System::Void button_000_click(system::object^ sender, System::EventArgs^ e) { This is a simple parser for Intel HEX files. At this point the parser is limited to record types 00 and 01. Also the file must include a RETURN at the on the last line. int state= 0; A state variable char line [100]; Next line char bytesstr[2]; Number of bytes (as a string) long bytes; Number of bytes (as an long integer) int byte_count; Current byte being processed char addr1str[2],addr2str[2]; Address MSB and LSB (as strings) long int addr1,addr2; Address MSB and LSB (as a long integer) long int address; Address (as one integer) char datastr[2]; Current data byte (as a string) long data; Current data byte (as a long integer) char checksumstr[2]; Checksum (as a string) long checksum; Checksum (as a long integer) bool eof_marker; True if we have found an end of file record bool success; True is the file completes successfully char ch; The current character in the line int pos; Position of the current character char file_001[100]; The file to be used for input s2=""; for (i=0; i<memorymax; i++) memory[i] = 0xFF; Initialise the array Get the input file name sprintf(file_001, "%s",this->textbox_001->text); FILE *InFile = fopen(file_001,"r"); Conversion to Char Initialise success=false; eof_marker=false; Loop through the file - line by line while (!feof(infile) &&!success) { fgets (line, 100, InFile); pos=0; while (line[pos]!=null &&!feof(infile)) { ch=line[pos]; if (ch!='\n') { if ((state==0) && (ch==':') && (pos==0)) {state = 1; : found else if ((state==1) && ((ch>='0' && ch<='9') (ch>='a' && ch<='f') (ch>='a' && ch<='f') ) ) { state = 2; bytesstr[0]=ch; else if ((state==2) && ((ch>='0' && ch<='9') (ch>='a' && ch<='f') (ch>='a' && ch<='f') ) ) { state = 3; bytesstr[1]=ch; bytes = strtol(bytesstr,null,16); byte_count=1; byte count found else if ((state==3) && ((ch>='0' && ch<='9') (ch>='a' && ch<='f') Rev: 1.4 (Apr 2009) Nano River Technolgies Page 44 of 67

45 (ch>='a' && ch<='f') ) ) {state = 4; addr1str[0]=ch; else if ((state==4) && ((ch>='0' && ch<='9') (ch>='a' && ch<='f') (ch>='a' && ch<='f') ) ) {state = 5; addr1str[1]=ch; else if ((state==5) && ((ch>='0' && ch<='9') (ch>='a' && ch<='f') (ch>='a' && ch<='f') ) ) {state = 6; addr2str[0]=ch; else if ((state==6) && ((ch>='0' && ch<='9') (ch>='a' && ch<='f') (ch>='a' && ch<='f') ) ) { state = 7; addr2str[1]=ch; addr1 = strtol(addr1str,null,16); addr2 = strtol(addr2str,null,16); address = addr1*256 + addr2; address found else if ((state==7) & (ch=='0')) state = 8; else if ((state==8) & (ch=='0' ch=='1')) { state = 9; if (ch=='1') { eof_marker=true; if (bytes==0) {state=11; record type (only 00 or 01 accepted) else if ((state==9) && ((ch>='0' && ch<='9') (ch>='a' && ch<='f') (ch>='a' && ch<='f') ) ) { state = 10; datastr[0]=ch; else if ((state==10) && ((ch>='0' && ch<='9') (ch>='a' && ch<='f') (ch>='a' && ch<='f') ) ) { state = 9; datastr[1]=ch; if (byte_count==bytes) { state=11; data = strtol(datastr,null,16); /*NEW*/ memory[address]=data; else { data = strtol(datastr,null,16); /*NEW*/ memory[address]=data; byte_count++; address++; data found else if ((state==11) && ((ch>='0' && ch<='9') (ch>='a' && ch<='f') (ch>='a' && ch<='f') ) ) { state = 12; checksumstr[0]=ch; else if ((state==12) && ((ch>='0' && ch<='9') (ch>='a' && ch<='f') (ch>='a' && ch<='f') ) ) { state = 25; if (eof_marker) { state=30; success=true; checksumstr[1]=ch; checksum = strtol(checksumstr,null,16); else if (state==20) state=20; else if (state==25) state=20; else if (state==30) state=30; else state=20; checksum found State 20 Error State State 25 End Of Line State 30 End of File /Successfull else { if (state==25) state=0; pos++; Rev: 1.4 (Apr 2009) Nano River Technolgies Page 45 of 67

46 fclose (InFile); if (success==true) s2="file read completed OK"; else { s2="error during file read!\n\n"; s2= System::String::Concat( s2,"file must be in Intel Hex format. "); s2= System::String::Concat( s2,"only supporting record type 00 and 01 at present.\n"); s2= System::String::Concat( s2,"must also include a RETURN on the last line.\n"); this->richtextbox_002->text = s2; Update the screen ScreenUpdate(); To follow is a function to take the programmer image, convert this to an intel hex file and then write the file to disk. private: System::Void button_001_click(system::object^ sender, System::EventArgs^ e) { Function to handle writing out the memory to file. char file_000[100]; Output file name int sum; The sum used in the checksum calculation int tmpsum; Temporary sum Get the output file name sprintf(file_000, "%s",this->textbox_002->text); Conversion to Char FILE *OutFile = fopen(file_000,"w"); for (j=0; j<(chip_size); j++) { if (((j)%16)==0) { fprintf (OutFile, ":10%04X00",j); sum = 0x10; Data Length tmpsum = j; ADD MSB of Address tmpsum = tmpsum & 0xFF00; tmpsum = tmpsum >> 8; sum = sum + tmpsum; tmpsum = 0xFF&(j); sum = sum + tmpsum; ADD LSB of Address fprintf (OutFile, "%02X",memory[j]); sum = sum + memory[j]; if (((j)%16)==15) { sum = sum & 0xFF; sum = sum; sum = sum & 0xFF; fprintf (OutFile, "%02X\n",sum); fprintf (OutFile, ": FF\n"); fclose (OutFile); s2="file write completed"; this->richtextbox_002->text = s2; Rev: 1.4 (Apr 2009) Nano River Technolgies Page 46 of 67

47 Two functions are provided to fill the programmer image 0xFF or with pseudo random numbers respectively. Upon completion the image window is updated. private: System::Void button_006_click(system::object^ sender, System::EventArgs^ e) { Function used to update all memory locations with random values srand(0); for (j=0; j<(chip_size); j++) { memory[j] = rand() & 0xFF; ScreenUpdate(); private: System::Void button_007_click(system::object^ sender, System::EventArgs^ e) { Function used to update all memory locations with FFs for (j=0; j<(chip_size); j++) { memory[j] = 0xFF; ScreenUpdate(); Some important links and includes are necessary in stdafx.h. This is best seen by viewing the file in the download from the web-site. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 47 of 67

48 6. IIC Command Tool (Linux and MacOS Versions) This example application is a C/C++ console application showing how to call functions associated with the IIC such as IIC read, IIC write, IIC scan and various configuration commands. The example is the same as the IIC Command Tool example from section 3, but ported to GCC for Linux and MacOS. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 48 of 67

49 6.1. Functionality The application works by prompting the user for a new command. There are three main types of commands that are accepted. IIC Scan Command %cmd> s Here the program will scan all IIC addresses and report which devices are connected to the bus. IIC Write Command %cmd> w devid <Device ID> -sa <Start Address> -l <Length> -d <Data Sequence> Here the user specifies the device ID, internal start address, transfer length and the data sequence. An IIC write transaction is then initiated. IIC Read Command %cmd> r devid <Device ID> -sa <Start Address> -l <Length> Here the user specifies the device ID, internal start address and transfer length. An IIC read transaction is then initiated and returns the read data. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 49 of 67

50 6.2. Project Structure This application is located in the Examples/ directory of the Linux and MacOS installation. The project file structure is implemented as follows. Examples/ common/ miniboard.h miniboard_class.h miniboard_class.c MiniBoard Header File MiniBoard Class Header File MiniBoard Class C++ File src/ IICCommandToolApplication.c Main Program (Top) scripts/ go_iiccommandtoolapplication Compile Script for Application The MiniBoard user interface is a simple class library of high level functions to control the board as I2C/SPI/GPIO or some combination. The class library is provided through miniboard_class.h and miniboard_class.c. The functions make simple calls to LibUsb OpenSource USB driver already assumed to have been installed as part of the installation process. In this example there is one main program IICCommandToolApplication.c. This program then makes calls to the class library to control in this case the I2C interface. A simple compile script has been provided to show exactly how to compile the application. This is go_iiccommandtoolapplication. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 50 of 67

51 To use this application, first navigate to the Examples/ directory. shell%> cd <installation_directory>/examples Next compile the application using the provided compile script. The compile script will use g++ for the compile. shell %>./scripts/go_iiccommandtoolapplication Finally run the application. shell %>./IICCommandToolApplication You should then be prompted for commands as shown earlier in this chapter Design Description The application (IICCommandToolApplication.c) is a port of the windows command tool application described in section 3 (IICCommandToolApplication.cpp). Please consult section 3 for a detailed description of the source code. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 51 of 67

52 7. Configuration Example (Linux and MacOS Versions) This is a very simple application giving a very basic setup for GPIO, I2C and SPI interfaces. The example does not show all possible configuration options. It is left to the user to read the API specification to see how to make more advanced applications. The example is meant as a starting point to show how to start developing applications for these interfaces. The example is provided for Linux and MacOS. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 52 of 67

53 7.1. Functionality The program runs through the following sequence. Step 1: USB connection In this step the program checks to see if it can establish connection to MiniBoard. Step2: GPIO Read/Write Two different patterns are written to the GPIO interface and then read back. Step3: I2C Read/Write Two different patterns are written to the I2C interface and then read back. This assumes a particular I2C command sequence for example a 2 byte start address etc as used for a standard I2C EEPROM. To talk with your own device you may need to change this. Step4: SPI Read/Write Two different patterns are written to the SPI interface and then read back. This assumes a particular SPI command sequence as used for a standard SPI EEPROM. To talk with your own device you may need to change this. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 53 of 67

54 7.2. Project Structure This application is located in the Examples/ directory of the Linux and MacOS installation. The project file structure is implemented as follows. Examples/ common/ miniboard.h miniboard_class.h miniboard_class.c MiniBoard Header File MiniBoard Class Header File MiniBoard Class C++ File src/ ConfigurationExample.c Main Program (Top) scripts/ go_configurationexample Compile Script for Application The MiniBoard user interface is a simple class library of high level functions to control the board as I2C/SPI/GPIO or some combination. The class library is provided through miniboard_class.h and miniboard_class.c. The functions make simple calls to LibUsb OpenSource USB driver already assumed to have been installed as part of the installation process. In this example there is one main program ConfigurationExample.c. This program then makes calls to the class library to control in this case the GPIO/I2C/SPI interfaces. A simple compile script has been provided to show exactly how to compile the application. This is go_configurationexample. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 54 of 67

55 To use this application, first navigate to the Examples/ directory. shell%> cd <installation_directory>/examples Next compile the application using the provided compile script. The compile script will use G++ for the compile. shell%>./scripts/go_configurationexample Finally run the application. shell%>./configurationexample You should then see data written to and read from the devices as shown earlier in this chapter. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 55 of 67

56 7.3. Design Description The application is implemented using a single file ConfigurationExample.c. The file starts by linking to the MiniBoard class library header file: Nano River Technologies File: ConfigurationExample (ConfigurationExample.c) Desciption: This is a simple command line application showing very simply how to start configuring the GPIO, SPI and I2C interfaces. This can be built upon by the user to create more advanced applications. Revision: Version 1.0 #include <stdio.h> #include <string.h> #include <stdbool.h> #include "../common/miniboard.h" #include "../common/miniboard_class.h" Next some global variables are defined. BOOL d; NANO_RESULT e; MBc MB; ULONG Value; BYTE SlaveAddress; ULONG StartAddress; BYTE StartAddressLength; WORD BufferLength; BYTE InBuffer[256]; BYTE OutBuffer[256]; BYTE in_buffer[512], out_buffer[512]; char c; int i; Rev: 1.4 (Apr 2009) Nano River Technolgies Page 56 of 67

57 The main program then starts by trying to connect to the MiniBoard. The program tells whether or not a connection was established. int main(void) { printf(" \n"); printf("++ NANO RIVER TECHNOLOGIES - CONFIGURATION EXAMPLE (MiniBoard) ++\n"); printf("++ (31 Oct 2008) ++\n"); printf(" \n\n"); printf ("<<<<< PRESS RETURN KEY >>>>>>\n"); c=getchar(); printf(" \n"); printf("open DEVICE...\n"); printf(" \n"); d=mb.opendevice(); if (d) printf (" MiniBoard Connected!!!\n"); else printf (" MiniBoard NOT Connected!!!\n"); printf(" \n\n"); printf ("<<<<< PRESS any KEY >>>>>>\n\n"); c=getchar(); Next the program tries to write and then read 0x and then 0xDEADBEEF to the GPIO interface. The results are displayed for the user. GPIO printf("gpio READ/WRITE...\n"); printf(" \n"); e=mb.nano_gpiosetdirection(mb.mb_hdevice,0xffffffff,0xffffffff); e=mb.nano_gpiowrite(mb.mb_hdevice,0x ,0xffffffff); printf("value (written) : %08X\n",0x ); e=mb.nano_gpioread(mb.mb_hdevice,&value); printf("readvalue (returned) : %08X\n",Value); e=mb.nano_gpiosetdirection(mb.mb_hdevice,0xffffffff,0xffffffff); e=mb.nano_gpiowrite(mb.mb_hdevice,0xdeadbeef,0xffffffff); printf("value (written) : %08X\n",0xDEADBEEF); e=mb.nano_gpioread(mb.mb_hdevice,&value); printf("readvalue (returned) : %08X\n",Value); printf(" \n"); Rev: 1.4 (Apr 2009) Nano River Technolgies Page 57 of 67

58 The program performs an IIC Write and then an IIC Read. Here we have assumed a 2 byte start address for a standard IIC EEPROM. The program writes and then reads 0x and then tries again with 0xDEADBEEF. IIC transactions occur at 400kBit/s fast rate. If these settings can not be used with your target device then consult the API specifications and change this code. IIC printf("iic READ/WRITE...\n"); printf(" \n"); e=mb.nano_iicsetfrequency(mb.mb_hdevice,nano_iic_freq_fast); SlaveAddress=0x50; StartAddress=0x0000; StartAddressLength=2; BufferLength=0x04; OutBuffer[0]=0x11; OutBuffer[1]=0x22; OutBuffer[2]=0x33; OutBuffer[3]=0x44; printf("value (written) : %02X%02X%02X%02X\n", OutBuffer[0],OutBuffer[1],OutBuffer[2],OutBuffer[3]); e=mb.nano_iicwrite(mb.mb_hdevice,slaveaddress,startaddresslength,startaddress, BufferLength,OutBuffer); for (i=0; i<256; i++) { InBuffer[i]=0; usleep (5000); This delay is for the device (to allow for write time) e=mb.nano_iicread(mb.mb_hdevice,slaveaddress,startaddresslength,startaddress, BufferLength,InBuffer); printf("value (read) : %02X%02X%02X%02X\n", InBuffer[0],InBuffer[1],InBuffer[2],InBuffer[3]); SlaveAddress=0x50; StartAddress=0x0000; BufferLength=0x04; OutBuffer[0]=0xDE; OutBuffer[1]=0xAD; OutBuffer[2]=0xBE; OutBuffer[3]=0xEF; printf("value (written) : %02X%02X%02X%02X\n", OutBuffer[0],OutBuffer[1],OutBuffer[2],OutBuffer[3]); e=mb.nano_iicwrite(mb.mb_hdevice,slaveaddress,startaddresslength,startaddress, BufferLength,OutBuffer); for (i=0; i<256; i++) { InBuffer[i]=0; usleep (5000); This delay is for the device (to allow for write time) e=mb.nano_iicread(mb.mb_hdevice,slaveaddress,startaddresslength,startaddress, BufferLength,InBuffer); printf("value (read) : %02X%02X%02X%02X\n", InBuffer[0],InBuffer[1],InBuffer[2],InBuffer[3]); printf(" \n"); Rev: 1.4 (Apr 2009) Nano River Technolgies Page 58 of 67

59 The program performs an SPI write enable, SPI write command and then an SPI read command with data of 0x The process is repeated with 0xDEADBEEF. The sequence assumes a standard SPI EEPROM. SPI transactions occur at 400kBit/s. If these settings can not be used with your target device then consult the API specifications and change this code. SPI printf("spi READ/WRITE...\n"); printf(" \n"); e=mb.nano_spisetclockconfig(mb.mb_hdevice,0x0, 0x0); e=mb.nano_spisetfrequency(mb.mb_hdevice,nano_spi_freq_400khz); Write Enable out_buffer[0] = 0x06; Opcode e=mb.nano_spireadwrite(mb.mb_hdevice, NANO_SPI_CHIPSELECT_CS, in_buffer, out_buffer, 0x01); Write out_buffer[0] = 0x02; Opcode out_buffer[1] = 0x00; Address out_buffer[2] = 0x00; Address out_buffer[3] = 0x11; Data out_buffer[4] = 0x22; Data out_buffer[5] = 0x33; Data out_buffer[6] = 0x44; Data printf("data written : %02X%02X%02X%02X\n", out_buffer[3],out_buffer[4],out_buffer[5],out_buffer[6],out_buffer[7]); e=mb.nano_spireadwrite(mb.mb_hdevice, NANO_SPI_CHIPSELECT_CS, in_buffer, out_buffer, 0x07); usleep(5000); Delay between reading and writing to ensure programming time Read out_buffer[0] = 0x03; Opcode out_buffer[1] = 0x00; Address out_buffer[2] = 0x00; Address e=mb.nano_spireadwrite(mb.mb_hdevice, NANO_SPI_CHIPSELECT_CS, in_buffer, out_buffer, 0x07); printf("data read : %02X%02X%02X%02X\n", in_buffer[3],in_buffer[4],in_buffer[5],in_buffer[6],in_buffer[7]); Write Enable out_buffer[0] = 0x06; Opcode e=mb.nano_spireadwrite(mb.mb_hdevice, NANO_SPI_CHIPSELECT_CS, in_buffer, out_buffer, 0x01); Write out_buffer[0] = 0x02; Opcode out_buffer[1] = 0x00; Address out_buffer[2] = 0x00; Address out_buffer[3] = 0xDE; Data out_buffer[4] = 0xAD; Data out_buffer[5] = 0xBE; Data out_buffer[6] = 0xEF; Data printf("data written : %02X%02X%02X%02X\n", out_buffer[3],out_buffer[4],out_buffer[5],out_buffer[6],out_buffer[7]); e=mb.nano_spireadwrite(mb.mb_hdevice, NANO_SPI_CHIPSELECT_CS, in_buffer, out_buffer, 0x07); usleep(5000); Delay between reading and writing to ensure programming time Read out_buffer[0] = 0x03; Opcode out_buffer[1] = 0x00; Address out_buffer[2] = 0x00; Address e=mb.nano_spireadwrite(mb.mb_hdevice, NANO_SPI_CHIPSELECT_CS, in_buffer, out_buffer, 0x07); printf("data read : %02X%02X%02X%02X\n", in_buffer[3],in_buffer[4],in_buffer[5],in_buffer[6],in_buffer[7]); printf(" \n"); Rev: 1.4 (Apr 2009) Nano River Technolgies Page 59 of 67

60 Finally the main program completes. Finished... printf(" \n"); printf(" TEST COMPLETE...\n"); printf(" \n"); printf("\n"); printf ("<<<<< PRESS RETURN KEY >>>>>>\n"); c=getchar(); / / return 0; Rev: 1.4 (Apr 2009) Nano River Technolgies Page 60 of 67

61 8. IIC Checker Tool (MacOS Xcode Cocoa) This example application is a GUI application for MacOS using Xcode and Cocoa. The example shows how to use the MiniBoard from Cocoa applications to call I2C scan commands. Whilst the example is developed using MacOS 10.5 and Xcode 3.1 other versions should link in the same way. Scan Button Text Box 8.1. Functionality In this application the user should just press the scan button. If devices are present then they will be listed in the textbox output. Missing MiniBoard connection and missing I2C devices are also messaged. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 61 of 67

62 8.2. Project Structure This project was created as a standard Cocoa application in Xcode. The project structure is shown below. MiniBoard Class Library (Cocoa version) MiniBoard Class Library Header File MiniBoard Header File Controller Object Header to Control Buttons Controller Object to Control Buttons Top Level Code Cocoa Project Definition LibUSB Library In the classes folder Cocoa versions of the MiniBoard Class Library and MiniBoard header file are placed. Some modification was needed from the one used for GCC applications owing to the linking between standard C and Object C++ so please make sure you use these for Cocoa applications. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 62 of 67

63 Also in the classes folder is an application controller object which has been built up and linked to button and textbox. It has an action called scan which is linked to the button and an outlet called textbox1 connected to the textbox. Coding for this will be discussed further on. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 63 of 67

64 The user window has been built up graphically by dragging and dropping objects from the Cocoa library for example labels, a button and the textbox. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 64 of 67

65 Linking to the LibUSB dynamic library is achieved by highlighting IICChecker under targets and then calling the information browser. By selecting + then one can find libusb.dynlib to add assuming that LibUSB has been installed before-hand. Rev: 1.4 (Apr 2009) Nano River Technolgies Page 65 of 67

Nano River Technologies October 2010

Nano River Technologies October 2010 October 2010 Rev: 1.1 (Oct 2010) Page 1 of 36 Table of Contents 1. PRELIMINARIES... 4 1.1. PACKAGING LIST... 4 1.2. GETTING HELP... 5 2. INSTALLATION (WINDOWS 2000 AND XP)... 6 2.1. VIPERBOARD INSTALLER...

More information

Given the C++ declaration statement below, which of the following represents the value of exforsys? e) None of the above. 1K

Given the C++ declaration statement below, which of the following represents the value of exforsys? e) None of the above. 1K Instruction: When specified, you may choose more than one answer; otherwise, choose ONE answer for each question. Choose the answer(s) by circling it/them on the Answer Sheet provided. Questions 1-12 are

More information

THE HONG KONG POLYTECHNIC UNIVERSITY Faculty of Engineering. Computer Programming Closed-book Written Test 3 Date: 28 March 2009 Time: 2:30 3:30 pm

THE HONG KONG POLYTECHNIC UNIVERSITY Faculty of Engineering. Computer Programming Closed-book Written Test 3 Date: 28 March 2009 Time: 2:30 3:30 pm THE HONG KONG POLYTECHNIC UNIVERSITY Faculty of Engineering Computer Programming Closed-book Written Test 3 Date: 28 March 2009 Time: 2:30 3:30 pm Name: Programme Code: Student No. This test aims at assessing

More information

Application Brief. Using the Total Phase CAN/I2C Activity Board Pro as an I2C- to- CAN Translator Application Brief by Rick Bogart

Application Brief. Using the Total Phase CAN/I2C Activity Board Pro as an I2C- to- CAN Translator Application Brief by Rick Bogart Using the Total Phase CAN/I2C Activity Board Pro as an I2C- to- CAN Translator Application Brief by Rick Bogart Introduction A customer request came in asking if we had a CAN to I2C translator. My first

More information

ASNTu2s PCB with Tiger Board USB to 7-Channel 3-Wire Interface Bridge Application Notes

ASNTu2s PCB with Tiger Board USB to 7-Channel 3-Wire Interface Bridge Application Notes ASNTu2s PCB with Tiger Board USB to 7-Channel 3-Wire Interface Bridge Application Notes Table of Contents Tiger Board Description... 2 ASNTu2s Description... 2 Software Installation... 3 Bridge and GUI

More information

Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic

Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic Outline 6.1 Test-Driving the Enhanced Inventory Application 6.2 Variables 6.3 Handling the TextChanged

More information

SwitchLinc 2-Wire Dimmer (RF Only) (2474DWH - Dev 0x01 / Sub 0x24)

SwitchLinc 2-Wire Dimmer (RF Only) (2474DWH - Dev 0x01 / Sub 0x24) Developer Notes SwitchLinc 2-Wire Dimmer v004 Developer Notes SwitchLinc 2-Wire Dimmer (RF Only) (2474DWH - Dev 0x01 / Sub 0x24) Version 003 April 23, 2012 Revision History Rev Date Comments 001 1/27/12

More information

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming

More information

USB-910H API DLL and Include File Reference Manual

USB-910H API DLL and Include File Reference Manual USB-910H API DLL and Include File Reference Manual APPLICABLE ADAPTERS This Application Note applies to the following Keterex products: KXUSB-910H. AN2101 Application Note INTRODUCTION The Keterex USB-910H

More information

UART TO SPI SPECIFICATION

UART TO SPI SPECIFICATION UART TO SPI SPECIFICATION Author: Dinesh Annayya dinesha@opencores.org Table of Contents Preface... 3 Scope... 3 Revision History... 3 Abbreviations... 3 Introduction... 3 Architecture... 4 Baud-rate generator

More information

Armide Documentation. Release Kyle Mayes

Armide Documentation. Release Kyle Mayes Armide Documentation Release 0.3.1 Kyle Mayes December 19, 2014 Contents 1 Introduction 1 1.1 Features.................................................. 1 1.2 License..................................................

More information

Lab 1: First Steps in C++ - Eclipse

Lab 1: First Steps in C++ - Eclipse Lab 1: First Steps in C++ - Eclipse Step Zero: Select workspace 1. Upon launching eclipse, we are ask to chose a workspace: 2. We select a new workspace directory (e.g., C:\Courses ): 3. We accept the

More information

Micro Module Shutter. Micro Module Shutter

Micro Module Shutter. Micro Module Shutter Developer Notes Micro Module Shutter Micro Module Shutter (XXXXX - Dev 0x01 / Sub 0xXX) Version 001 June 28, 2012 Revision History Rev Date Comments 001 6/28/12 Initial Release Table of Contents Firmware

More information

I2C and SPI Foundation

I2C and SPI Foundation Revision 30 September 2010 Release I2C and SPI Foundation 17 March 2018 changed ref: command f to x Introduction I2C (I squared C) and SPI (Serial peripheral Interface) are two main ways that microcontrollers

More information

C Refresher, Advance C, Coding Standard, Misra C Compliance & Real-time Programming

C Refresher, Advance C, Coding Standard, Misra C Compliance & Real-time Programming C Refresher, Advance C, Coding Standard, Misra C Compliance & Real-time Programming Course Overview This course transforms an IT-Professional or a Student into an expert C Programming Person with concepts

More information

UM1064 User manual. Software guide for Unico Lite. Introduction

UM1064 User manual. Software guide for Unico Lite. Introduction UM1064 User manual Software guide for Unico Lite Introduction The Unico Lite graphical user interface (GUI) is a complete demonstration software which provides the source code to show how to manage sensor

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

LatticeMico32 SPI Flash Controller

LatticeMico32 SPI Flash Controller LatticeMico32 SPI Flash Controller The LatticeMico32 Serial Peripheral Interface (SPI) flash controller is a WISHBONE slave device that provides an industry-standard interface between a LatticeMico32 processor

More information

Program Organization and Comments

Program Organization and Comments C / C++ PROGRAMMING Program Organization and Comments Copyright 2013 Dan McElroy Programming Organization The layout of a program should be fairly straight forward and simple. Although it may just look

More information

USER MANUAL EXPERIENCE INCREDIBLE PERFORMANCE V2.3

USER MANUAL EXPERIENCE INCREDIBLE PERFORMANCE V2.3 USER MANUAL EXPERIENCE INCREDIBLE PERFORMANCE V2.3 CONTENTS 1 INTRODUCTION... 3 2 INTERFACE DESIGN... 4 2.1 Connectivity... 5 2.2 Analog Interface... 6 2.3 I 2 C Interface... 7 2.4 I 2 C Operations...

More information

Venstar Thermostat Adapter

Venstar Thermostat Adapter Developer Venstar Thermostat Adapter v001 Developer Venstar Thermostat Adapter Version 001 May 23, 2013 Revision History Rev Date Comments 001 05/23/13 Initial Release Page 1 of 13 Table of Contents 1

More information

INSTEON Hidden Door Sensor

INSTEON Hidden Door Sensor Developer Notes INSTEON Door Sensor Developer Notes INSTEON Hidden Door Sensor Version 005 October 18, 2013 Revision History Rev Date Comments 001 4/15/13 Initial Release 002 8/2/13 Updated s 003 9/6/13

More information

QBridge. I2C, SPI, CAN Control Software User s Manual. Date: Rev 1.3

QBridge. I2C, SPI, CAN Control Software User s Manual. Date: Rev 1.3 QBridge I2C, SPI, CAN Control Software User s Manual Date: 9-10-2005 Rev 1.3 1. Introduction...1 1.1. What QBridge can do?... 1 1.2. Disclaimer... 1 1.3. Operational Format... 1 1.4. QBridge-V2... 1 2.

More information

Bootloader project Project with a Bootloader Component and communication Component.

Bootloader project Project with a Bootloader Component and communication Component. PSoC Creator Component Datasheet Bootloader and Bootloadable 1.60 Features Separate Bootloader and Bootloadable Components Configurable set of supported commands Flexible Component configuration General

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Application Note: AN00152 xscope - Bi-Directional Endpoint

Application Note: AN00152 xscope - Bi-Directional Endpoint Application Note: AN00152 xscope - Bi-Directional Endpoint This application note shows how to create a simple example which uses the XMOS xscope application trace system to provide bi-directional communication

More information

Using Embedded Tools for I2C, SPI, and USB Debugging for the Renesas RX63N RDK

Using Embedded Tools for I2C, SPI, and USB Debugging for the Renesas RX63N RDK Using Embedded Tools for I2C, SPI, and USB Debugging for the Renesas RX63N RDK Renesas Electronics America Inc. Renesas Technology & Solution Portfolio 2 Agenda Introduction to the Renesas RX63N RDK Introduction

More information

Reprinted by permission of T&L Publications Inc. Copyright 2001 USB MICROCONTROLLERS FOR THE MASSES

Reprinted by permission of T&L Publications Inc. Copyright 2001 USB MICROCONTROLLERS FOR THE MASSES Reprinted by permission of T&L Publications Inc. Copyright 2001 USB MICROCONTROLLERS FOR THE MASSES By Don L. Powrie Microcontroller, Flash programmer, and high speed USB-to-PC interface all in one tidy

More information

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is

More information

Read section 8 of this document for detailed instructions on how to use this interface spec with LibUSB For OSX

Read section 8 of this document for detailed instructions on how to use this interface spec with LibUSB For OSX CP2130 INTERFACE SPECIFICATION 1. Introduction The Silicon Labs CP2130 USB-to-SPI bridge is a device that communicates over the Universal Serial Bus (USB) using vendor-specific control and bulk transfers

More information

F²MC-8FX FAMILY 8-BIT MICROCONTROLLER MB95200H SERIES SPI SW REALIZATION USING GPIO APPLICATION NOTE

F²MC-8FX FAMILY 8-BIT MICROCONTROLLER MB95200H SERIES SPI SW REALIZATION USING GPIO APPLICATION NOTE Fujitsu Semiconductor (Shanghai) Co., Ltd. Application Note MCU-AN-500035-E-10 F²MC-8FX FAMILY 8-BIT MICROCONTROLLER MB95200H SERIES SPI SW REALIZATION USING GPIO APPLICATION NOTE Revision History Revision

More information

ice40 UltraPlus Image Sensor Elliptical Crypto Engine (ECC) Demo - Radiant Software User Guide

ice40 UltraPlus Image Sensor Elliptical Crypto Engine (ECC) Demo - Radiant Software User Guide ice40 UltraPlus Image Sensor Elliptical Crypto Engine (ECC) Demo - Radiant Software FPGA-UG-02060 Version 1.0 June 2018 Contents Acronyms in This Document... 3 1. Introduction... 4 2. Functional Description...

More information

Serial Communication. Simplex Half-Duplex Duplex

Serial Communication. Simplex Half-Duplex Duplex 1.5. I/O 128 Serial Communication Simplex Half-Duplex Duplex 129 Serial Communication Master-Slave Master Master-Multi-Slave Master Slave Slave Slave (Multi-)Master Multi-Slave Master Slave Slave Slave

More information

MPX-24794S Serial USB Card

MPX-24794S Serial USB Card MPX-24794S Serial USB Card SPI Master, I2C Master, Counter, GPIO through USB Interfaces Programmer s Manual Version 1.10 Taiwan Commate Computer Inc. 1 Taiwan Commate Computer Inc. 2012, 2013 TCC reserves

More information

Note that FLIP is an Atmel program supplied by Crossware with Atmel s permission.

Note that FLIP is an Atmel program supplied by Crossware with Atmel s permission. INTRODUCTION This manual will guide you through the first steps of getting the SE-8051ICD running with the Crossware 8051 Development Suite and the Atmel Flexible In-System Programming system (FLIP). The

More information

AN022: The Bootloader Protocol

AN022: The Bootloader Protocol APPLICATION NOTE AN022: The Bootloader Protocol Document Revision V2.00 2018-APR-04 This application note describes the protocol used to update the firmware of a Trinamic module or a Trinamic evaluation

More information

FLASH Programming in Production of VS1000 Applications

FLASH Programming in Production of VS1000 Applications FLASH Programming in Production of VS1000 Applications Purpose This document describes the different possibilities for programming firmware and content to VS1000-based systems in production. Revision History

More information

C++ For Science and Engineering Lecture 12

C++ For Science and Engineering Lecture 12 C++ For Science and Engineering Lecture 12 John Chrispell Tulane University Monday September 20, 2010 Comparing C-Style strings Note the following listing dosn t do what you probably think it does (assuming

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous

More information

Altera DE2 I2C Driver. Daniel Fiske Michael Lam Daniel Tiam

Altera DE2 I2C Driver. Daniel Fiske Michael Lam Daniel Tiam Altera DE2 I2C Driver Daniel Fiske Michael Lam Daniel Tiam Preface This application note is based on the previous application note [1] released by Braedan Jongerius, Michael Jun and Scott Hewson in the

More information

JENET C LIBRARY API ver. 3.00

JENET C LIBRARY API ver. 3.00 JENET C LIBRARY API ver. 3.00 Document Version: 2.0 Document Revision: November, 29 2007 FP, UZ, MV Helper function library for developing user applications to control a Jenet Ethernet Camac Crate Controller.

More information

CS2141 Software Development using C/C++ C++ Basics

CS2141 Software Development using C/C++ C++ Basics CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short

More information

Developer Notes for KeypadLinc Line

Developer Notes for KeypadLinc Line Developer Notes for KeypadLinc Line Version 003 April 16, 2013 Revision History Rev Date Comments 001 1/11/13 Initial Release 002 1/22/13 Update s 003 4/16/13 Updated s Table of Contents 1 SUPPORTED DEVICES...

More information

Bootloader Design Techniques for Microcontrollers

Bootloader Design Techniques for Microcontrollers Bootloader Design Techniques for Microcontrollers Jacob Beningo Beningo Embedded Group Speaker/Author Details : jacob@beningo.com : 810-844-1522 : Jacob_Beningo : Beningo Engineering : JacobBeningo : Embedded

More information

/* defines are mostly used to declare constants */ #define MAX_ITER 10 // max number of iterations

/* defines are mostly used to declare constants */ #define MAX_ITER 10 // max number of iterations General Framework of a C program for MSP430 /* Compiler directives (includes & defines) come first */ // Code you write in this class will need this include #include msp430.h // CCS header for MSP430 family

More information

General Purpose GUI Overview

General Purpose GUI Overview General Purpose GUI Overview May 2008 Revised July 2008 TMS320C2000 Systems Applications Collateral The Generic GUI is an easy to use tool designed to simplify demos by allowing the user to graphically

More information

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types

More information

Detecting Errors in the Dual Port TPU RAM (DPTRAM) Module

Detecting Errors in the Dual Port TPU RAM (DPTRAM) Module Freescale Semiconductor Order this document by: AN2192/D Detecting Errors in the Dual Port TPU RAM (DPTRAM) Module by Jeff Loeliger Rev. 0, 10 September 2001 1 Overview The integrity of the data in the

More information

Dragon12 LCD Displays Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) Dragon12 LCD Display. The Dragon12 board has a 16 character x 2 line display

Dragon12 LCD Displays Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) Dragon12 LCD Display. The Dragon12 board has a 16 character x 2 line display Dragon12 LCD Displays Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) o Using the Dragon12 LCD display Dragon12 LCD Display The Dragon12 board has a 16 character x 2 line display Each character is a 5x7

More information

17. I 2 C communication channel

17. I 2 C communication channel 17. I 2 C communication channel Sometimes sensors are distant to the microcontroller. In such case it might be impractical to send analog signal from the sensor to the ADC included in the microcontroller

More information

ZIO Java API. Tutorial. 1.2, Feb 2012

ZIO Java API. Tutorial. 1.2, Feb 2012 ZIO Java API Tutorial 1.2, Feb 2012 This work is licensed under the Creative Commons Attribution-Share Alike 2.5 India License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/in/

More information

Freescale Semiconductor, I

Freescale Semiconductor, I nc. Application Note Rev. 0, 4/2004 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs By John Logan 8/16-Bit Division East Kilbride, Scotland Introduction This application note describes

More information

PusleIR Multitouch Screen Software SDK Specification. Revision 4.0

PusleIR Multitouch Screen Software SDK Specification. Revision 4.0 PusleIR Multitouch Screen Software SDK Specification Revision 4.0 Table of Contents 1. Overview... 3 1.1. Diagram... 3 1.1. PulseIR API Hierarchy... 3 1.2. DLL File... 4 2. Data Structure... 5 2.1 Point

More information

USB-I2C USB to I2C Communications Module Technical Specification

USB-I2C USB to I2C Communications Module Technical Specification Page 1 of 7 USB-I2C USB to I2C Communications Module Technical Specification The USB-I2C module provides a complete interface between your PC and the I2C bus. The module is self powered from the USB cable

More information

Keithley KPCI-3160 Series

Keithley KPCI-3160 Series Keithley KPCI-3160 Series Information in this document is subject to change without notice. The software described is this document is furnished under a license agreement. The software may be used or copied

More information

Migrating to Venom2. Part 1: Language Changes

Migrating to Venom2. Part 1: Language Changes Migrating to Venom2 The release of VM2 a completely new VM hardware platform made some degree of change to the Venom language unavoidable. So, as any code ported from VM1 to VM2 would have to be edited

More information

Parallel Data Transfer. Suppose you need to transfer data from one HCS12 to another. How can you do this?

Parallel Data Transfer. Suppose you need to transfer data from one HCS12 to another. How can you do this? Introduction the Serial Communications Huang Sections 9.2, 10.2, 11.2 SCI Block User Guide SPI Block User Guide IIC Block User Guide o Parallel vs Serial Communication o Synchronous and Asynchronous Serial

More information

ECE 598 Advanced Operating Systems Lecture 6

ECE 598 Advanced Operating Systems Lecture 6 ECE 598 Advanced Operating Systems Lecture 6 Vince Weaver http://www.eece.maine.edu/~vweaver vincent.weaver@maine.edu 3 February 2015 Announcements Homework #2 will be released shortly Raspberry Pi 2???

More information

CANopen Win API. Version TK Engineering Oy

CANopen Win API. Version TK Engineering Oy Author SB/HL Checked Approved Type Guideline Name CANopen Win API Department R&D File Name CANopen Win API - API Documentation.odt Revision $Rev: $ Copyright TK Engineering Oy. All rights reserved. Reproduction,

More information

CC2650 Java SBL Imp CC2650.

CC2650 Java SBL Imp CC2650. Author: David Agassi Date: 12/04/17 Abstract This project implements a simple Serial BootLoader for TI cc2650 using the SBL backdoor on the chip. It uses the RXTX java (serial and parallel communication

More information

ArduCAM-M-2MP Camera Shield

ArduCAM-M-2MP Camera Shield 33275-MP ArduCAM-M-2MP Camera Shield 2MP SPI Camera Hardware Application Note Rev 1.0, Mar 2015 33275-MP ArduCAM-M-2MP Hardware Application Note Table of Contents 1 Introduction... 2 2 Typical Wiring...

More information

VS10XX REAL-TIME MIDI INPUT

VS10XX REAL-TIME MIDI INPUT SOFTWARE DOCUMENT VS10XX REAL-TIME MIDI INPUT VLSI Solution Audio Decoder Project Code: Project Name: All information in this document is provided as-is without warranty. Features are subject to change

More information

I2C a learn.sparkfun.com tutorial

I2C a learn.sparkfun.com tutorial I2C a learn.sparkfun.com tutorial Available online at: http://sfe.io/t82 Contents Introduction Why Use I2C? I2C at the Hardware Level Protocol Resources and Going Further Introduction In this tutorial,

More information

8051 Microcontroller

8051 Microcontroller 8051 Microcontroller The 8051, Motorola and PIC families are the 3 leading sellers in the microcontroller market. The 8051 microcontroller was originally developed by Intel in the late 1970 s. Today many

More information

Communications API. TEAM A : Communications and Integration Group. April 15, 1995

Communications API. TEAM A : Communications and Integration Group. April 15, 1995 Communications API TEAM A : Communications and Integration Group April 15, 1995 1 Introduction This document specifies the API provided by the Communications and Integration group for use in the AMC system.

More information

Software Development With Emacs: The Edit-Compile-Debug Cycle

Software Development With Emacs: The Edit-Compile-Debug Cycle Software Development With Emacs: The Edit-Compile-Debug Cycle Luis Fernandes Department of Electrical and Computer Engineering Ryerson Polytechnic University August 8, 2017 The Emacs editor permits the

More information

Convertor Binar -> Zecimal Rosu Alin, Calculatoare, An2 Mod de Functionare: Am creat un program, in Windows Form Application, care converteste un

Convertor Binar -> Zecimal Rosu Alin, Calculatoare, An2 Mod de Functionare: Am creat un program, in Windows Form Application, care converteste un Convertor Binar -> Zecimal Rosu Alin, Calculatoare, An2 Mod de Functionare: Am creat un program, in Windows Form Application, care converteste un numar binar, in numar zecimal. Acest program are 4 numericupdown-uri

More information

Microcontrollers and Interfacing

Microcontrollers and Interfacing Microcontrollers and Interfacing Week 10 Serial communication with devices: Serial Peripheral Interconnect (SPI) and Inter-Integrated Circuit (I 2 C) protocols College of Information Science and Engineering

More information

Application Note: AN00151 xscope - Custom Host Endpoint

Application Note: AN00151 xscope - Custom Host Endpoint Application Note: AN00151 xscope - Custom Host Endpoint This application note shows how to create a simple example which uses the XMOS xscope application trace system to provide instrumentation logging

More information

SC5360B Manual SC5360B. 9.3 GHz Dual Channel Phase Coherent RF Downconverter. Core Module with USB and SPI

SC5360B Manual SC5360B. 9.3 GHz Dual Channel Phase Coherent RF Downconverter. Core Module with USB and SPI SC5360B SC5360B Manual 9.3 GHz Dual Channel Phase Coherent RF Downconverter Core Module with USB and SPI 2015 SignalCore, Inc. support@signalcore.com SC5360B Table of Contents Theory and Operation... 3

More information

Application Note, V1.0, Jul AP XC16x. Interfacing the XC16x Microcontroller to a Serial SPI EEPROM. Microcontrollers

Application Note, V1.0, Jul AP XC16x. Interfacing the XC16x Microcontroller to a Serial SPI EEPROM. Microcontrollers Application Note, V1.0, Jul. 2006 AP16095 XC16x Interfacing the XC16x Microcontroller to a Serial SPI EEPROM Microcontrollers Edition 2006-07-10 Published by Infineon Technologies AG 81726 München, Germany

More information

CS16 Exam #1 7/17/ Minutes 100 Points total

CS16 Exam #1 7/17/ Minutes 100 Points total CS16 Exam #1 7/17/2012 75 Minutes 100 Points total Name: 1. (10 pts) Write the definition of a C function that takes two integers `a` and `b` as input parameters. The function returns an integer holding

More information

Tutorial 5 Completing the Inventory Application Introducing Programming

Tutorial 5 Completing the Inventory Application Introducing Programming 1 Tutorial 5 Completing the Inventory Application Introducing Programming Outline 5.1 Test-Driving the Inventory Application 5.2 Introduction to C# Code 5.3 Inserting an Event Handler 5.4 Performing a

More information

EL-USB-RT API Guide V1.0

EL-USB-RT API Guide V1.0 EL-USB-RT API Guide V1.0 Contents 1 Introduction 2 C++ Sample Dialog Application 3 C++ Sample Observer Pattern Application 4 C# Sample Application 4.1 Capturing USB Device Connect \ Disconnect Events 5

More information

SPI Framework Module Guide

SPI Framework Module Guide Application Note Introduction This module guide will enable you to effectively use a module in your own design. Upon completion of this guide, you will be able to add this module to your own design, configure

More information

Keyboards. The PS/2 Protocol

Keyboards. The PS/2 Protocol Keyboards The PS/2 Protocol Debugging Always start from a known working state; stop in a working state. If it breaks, what changed? Take a simple small step, check it carefully, then take another small

More information

Fredrick M. Cady. Assembly and С Programming forthefreescalehcs12 Microcontroller. шт.

Fredrick M. Cady. Assembly and С Programming forthefreescalehcs12 Microcontroller. шт. SECOND шт. Assembly and С Programming forthefreescalehcs12 Microcontroller Fredrick M. Cady Department of Electrical and Computer Engineering Montana State University New York Oxford Oxford University

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

Using the Z8051 MCU s USI Peripheral as an SPI Interface

Using the Z8051 MCU s USI Peripheral as an SPI Interface Using the Z8051 MCU s USI Peripheral as an SPI Interface AN035901-0513 Abstract This document describes how to configure Zilog s Z8051 Universal Serial Interface (USI) peripheral to operate as Serial Peripheral

More information

ECE2049-E18 Lecture 6 Notes 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review

ECE2049-E18 Lecture 6 Notes 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review ECE2049-E18 Lecture 6 Notes 1 ECE2049: Embedded Computing in Engineering Design E Term 2018 Lecture #6: Exam Review Administrivia Exam 1: Next Tuesday (6/5) HW4: Short assignment, due Tuesday Lab 1: Due

More information

Generalised User Interface for Embedded Applications using an LCD screen and keypad.

Generalised User Interface for Embedded Applications using an LCD screen and keypad. Generalised User Interface for Embedded Applications using an LCD screen and keypad. This article is concerned with firmware design and implementation for microcontroller-based devices incorporating a

More information

App Note Application Note: Addressing Multiple FPAAs Using a SPI Interface

App Note Application Note: Addressing Multiple FPAAs Using a SPI Interface Rev: 1.0.0 Date: 23 rd Jan 2015 App Note - 310 Application Note: Addressing Multiple FPAAs Using a SPI Interface TABLE OF CONTENTS 1 PURPOSE... 2 2 THE SPI INTERFACE... 3 2.1 OVERVIEW... 3 2.2 DETAILED

More information

Laboratory 5 Communication Interfaces

Laboratory 5 Communication Interfaces Laboratory 5 Communication Interfaces Embedded electronics refers to the interconnection of circuits (micro-processors or other integrated circuits) with the goal of creating a unified system. In order

More information

Summary of basic C++-commands

Summary of basic C++-commands Summary of basic C++-commands K. Vollmayr-Lee, O. Ippisch April 13, 2010 1 Compiling To compile a C++-program, you can use either g++ or c++. g++ -o executable_filename.out sourcefilename.cc c++ -o executable_filename.out

More information

Design UART Loopback with Interrupts

Design UART Loopback with Interrupts Once the E is displayed, will the 0 reappear if you return the DIP switch to its OFF position and re-establish the loopback path? Usually not. When you break the loopback path, it will most likely truncate

More information

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #9: Exam Review w/ Solutions

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #9: Exam Review w/ Solutions ECE2049: Embedded Computing in Engineering Design A Term Fall 2018 Lecture #9: Exam Review w/ Solutions Reading for Today: Review all reading and notes, Davies Ch 1, 2, 4,7, MSP430 User's Guide Ch 6.1,

More information

Serial communications with SPI

Serial communications with SPI Serial communications with SPI DRAFT VERSION - This is part of a course slide set, currently under development at: http://mbed.org/cookbook/course-notes We welcome your feedback in the comments section

More information

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. 1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format

More information

BioTac C Library Manual for Cheetah

BioTac C Library Manual for Cheetah BioTac C Library Manual for Cheetah Version 1.1.0 Chia- Hsien (Gary) Lin Tomonori Yamamoto Jeremy Fishel April 5, 2012 Released 1 Table of Contents 1 Introduction... 3 2 General Data Types... 3 3 Functions...

More information

Maths 1264 Quiz 1 answers Thursday 22/1/15

Maths 1264 Quiz 1 answers Thursday 22/1/15 Maths 1264 Quiz 1 answers Thursday 22/1/15 (it is ok to use notes and to collaborate) On Intel machines, ints and short ints are stored little endian, but in these hand-calculations they should be written

More information

SpiNNaker Application Programming Interface (API)

SpiNNaker Application Programming Interface (API) SpiNNaker Application Programming Interface (API) Version 2.0.0 10 March 2016 Application programming interface (API) Event-driven programming model The SpiNNaker API programming model is a simple, event-driven

More information

User Manual. SUSI Library

User Manual. SUSI Library User Manual SUSI Library Copyright The documentation and the software included with this product are copyrighted 2009 by Advantech Co., Ltd. All rights are reserved. Advantech Co., Ltd. reserves the right

More information

STD_CU43USBSW_V1.0E. CUnet (MKY43) USB Unit. CU-43USB Software Manual

STD_CU43USBSW_V1.0E. CUnet (MKY43) USB Unit. CU-43USB Software Manual STD_CU43USBSW_V1.0E CUnet (MKY43) USB Unit CU-43USB Software Manual Introduction This document describes API included with CU-43USB unit. Before using the product, please check the latest information on

More information

2. Numbers In, Numbers Out

2. Numbers In, Numbers Out COMP1917: Computing 1 2. Numbers In, Numbers Out Reading: Moffat, Chapter 2. COMP1917 15s2 2. Numbers In, Numbers Out 1 The Art of Programming Think about the problem Write down a proposed solution Break

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

AN2737 Application note Basic in-application programming example using the STM8 I 2 C and SPI peripherals Introduction

AN2737 Application note Basic in-application programming example using the STM8 I 2 C and SPI peripherals Introduction Application note Basic in-application programming example using the STM8 I 2 C and SPI peripherals Introduction This application note is one of a set of application notes giving examples of how to use

More information

Project 15 - Reading a keypad with the Raspberry Pi

Project 15 - Reading a keypad with the Raspberry Pi Project 15 - Reading a keypad with the Raspberry Pi Outline This application note describes how to read a 3 x 4 data keypad using the Raspberry Pi. Any of the Raspberry Pi models can be used including

More information

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world alun@debian:~$ gcc hello.c alun@debian:~$ a.out Hello, world alun@debian:~$ gcc -o hello hello.c alun@debian:~$ hello Hello, world alun@debian:~$ 1 A Quick guide to C for Networks and Operating Systems

More information

RVDS 4.0 Introductory Tutorial

RVDS 4.0 Introductory Tutorial RVDS 4.0 Introductory Tutorial 402v02 RVDS 4.0 Introductory Tutorial 1 Introduction Aim This tutorial provides you with a basic introduction to the tools provided with the RealView Development Suite version

More information

Getting started with E909.06

Getting started with E909.06 preliminary Getting started with E909.06 Overview of software and tools Version 1.00 14.04.2015 Mechaless Systems GmbH TRIWO Technopark Bruchsal Werner-von-Siemens-Str. 2-6 Building 5108 76646 Bruchsal

More information