Main Page | Modules | Related Pages | Examples

Application and Its Life Cycle

By application we mean mainly the Turbo Programmer object, i.e. the trb file that is uploaded into the programmer. In many cases it is useful to write a PC side application that send specific actions and receives results. This PC side application should be linked against libprog.a - small library containing the usb protocol for actions passing. It is open source and part of turbo-prog-utils package.

In the turbo-prog-utils there are 4 applications with both programmer and PC side:

All of them are preloaded in the programmer.

Application Management

All the application management is done with the help of the prog_apps utility. It allows to:

List Applications


Upload Application

prog_apps -u app.trb

Remove Application

prog_apps -r app.trb


prog_apps -i 

Action Triggering

prog_apps -a application_number -x action_number -s data

PC side application skelet

The myapp.h should contain the defines for APP_MY, ACTION_MY_INIT, ACTION_MY_DO_SOMETHING, etc. with same values as used in the programmer application.

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

#include <tprog/tproglib.h>
#include "../module-src/myapp.h"

void help ()
  printf ("Usage: myapp\n");
  printf ("-a application\tuse application, default is %s\n", APP_AVR_PROG);
  printf ("-d device\tuse USB device, default is %s\n", USBDEVICE);
  printf ("-h\t\thelp\n");
  printf ("-v\t\tverbose\n");
  exit (-1);

int main (int argc, char **argv)
  int result;
  u8 *dev = USBDEVICE;
  u8 *app_name = APP_MY;
  u8 answer[2048];
  u16 answerLen;
  u16 i;

    result = getopt (argc, argv, "hd:a:v");
    switch (result)
      case 'a':
        app_name = optarg;
      case 'd':
        dev = optarg;
      case 'h':
        help ();
      case 'v':
        verbose_inc ();
  while (result > 0);

  open_device (dev);
  if (select_app (app_name) != NO_ERROR)
    close_device ();
    fprintf (stderr, "Cannot open application %s\n", app_name);
    exit (-1);

  usb_send (ACTION_MY_INIT, 0, NULL, &answerLen, answer);
  printf ("MY APP initialized, %s\n", app_name);

  usb_send (ACTION_MY_DO_SOMETHING, 0, NULL, &answerLen, answer);
  printf ("Answer ");
  for (i = 0; i < answerLen; i++)
  printf ("%02X", answer[0]);

  close_device ();

Copyright © 2004 BLADOX
Turbo Programmer version 2.0