Main Page | Modules | Related Pages | Examples

Getting Started, Hello World!

Hello World!

This section tells you how to write applications for Turbo Programmer.

We start with a simple hello-world example.

 * Copyright (C) 2004 BLADOX, s.r.o.  All rights reserved.
 * This file is part of an example program for Turbo. This example
 * program may be used, distributed and modified without limitation.

#include <config.h>
#include <tprog/tprog.h>

u8 PROGMEM hello[] = "helloworld!";

void turbo_handler (u8 action, USB_Data *data)
  switch (action)
    case 0x80:
        usb_send (NO_ERROR, sizeof (hello), hello);

You can see there is one function in this example:

This function is required for every application and has to be called turbo_handler().

Your application code must include the turbo_handler() function.
The turbo_handler() function is a handler - it receives actions and somehow handles them.
We could call the "action" also "event" or "signal" as well, but we decided to use the term action (ACTION_SOMETHING).

Application structure

So handler receives actions and somehow reacts. There are actions related to:

For more see Actions.

In our hello-world example we handle just one action 0x80. It responds with "helloworld!" string.

prog_apps                       # you get the application number list
prog_apps -a app_nr -x 128      # send the 0x80 action to the application

Application Persistent Data

Application can store data in the EEPROM. The question is how to store the pointer on such data - it cannot be in RAM because its value would be lost after reset. So it has to be in EEPROM - pointer stored in EEPROM on data stored in EEPROM. The solution are the reg_app_data() and app_data() calls.

Typical example of persistent data usage

typedef struct _My_Persistent_Data
u8      x;
u16     y;
u8 *    p1;
} My_Persistent_Data;

u8 x;
u16 y;
u8 *p1;

void turbo_handler (u8 action, void *data)
  switch (action)
        My_Persistent_Data *p = emalloc (sizeof (My_Persistent_Data));
        wb (&p->x, 0);
        ww (&p->y, 0x1234);
        ww (&p->p1, NULL);

        reg_app_data (p);
        My_Persistent_Data *p = app_data ();
        efree (rw (&p->p1));
        efree (p);
        My_Persistent_Data *p = app_data ();

        x = rb (&p->x);
        y = rw (&p->y);
        p1 = rw (&p->p1);

Copyright © 2004 BLADOX
Turbo Programmer version 2.0