Synopsis

struct              NtdStm;
struct              NtdStmClass;
NtdStmAnswer        ntd_stm_answered                    (NtdStm *stm);
gboolean            ntd_stm_command                     (NtdStm *stm,
                                                         NtdStmCommand command);
gboolean            ntd_stm_data                        (NtdStm *stm,
                                                         gconstpointer data,
                                                         guint data_size);
const guchar *      ntd_stm_get_code_table              (NtdStm *stm);
gulong              ntd_stm_get_flash_base              (NtdStm *stm);
guint               ntd_stm_get_pid                     (NtdStm *stm);
const gchar *       ntd_stm_get_version                 (NtdStm *stm);
NtdStm *            ntd_stm_new                         (void);
NtdStm *            ntd_stm_new_with_device             (const gchar *device);
void                ntd_stm_set_code_table              (NtdStm *stm,
                                                         const guchar *code_table);
void                ntd_stm_set_flash_base              (NtdStm *stm,
                                                         gulong flash_base);
void                ntd_stm_set_pid                     (NtdStm *stm,
                                                         guint pid);
void                ntd_stm_set_version                 (NtdStm *stm,
                                                         const gchar *version);

Object Hierarchy

  GObject
   +----NtdIsp
         +----NtdStm

Properties

  "code-table"               gpointer              : Read / Write
  "flash-base"               gulong                : Read / Write
  "pid"                      guint                 : Read / Write
  "version"                  gchar*                : Read / Write

Description

Details

struct NtdStm

struct NtdStm;

All fields are private and should not be used directly. Use its public methods instead.


struct NtdStmClass

struct NtdStmClass {
    /* Signals */
};

ntd_stm_answered ()

NtdStmAnswer        ntd_stm_answered                    (NtdStm *stm);

Checks the response of a packet.

stm :

a NtdStm

Returns :

a constant identifing the response type: NTD_STM_ANSWER_NONE if timed out, NTD_STM_ANSWER_ACK if 0x79 is received, NTD_STM_ANSWER_NAK when 0x1F is received, NTD_STM_ANSWER_UNKNOWN when unknows data is received.

ntd_stm_command ()

gboolean            ntd_stm_command                     (NtdStm *stm,
                                                         NtdStmCommand command);

Sends command, together with the needed protocol stuff, to the device identified by stm.

stm :

a NtdStm

command :

the command

Returns :

TRUE on success, FALSE otherwise

ntd_stm_data ()

gboolean            ntd_stm_data                        (NtdStm *stm,
                                                         gconstpointer data,
                                                         guint data_size);

Sends a chunk of generic data to stm: this method basically adds the XOR checksum, as required by the STM protocol.

stm :

a NtdStm

data :

a buffer of data

data_size :

size of the buffer

Returns :

TRUE on success, FALSE otherwise

ntd_stm_get_code_table ()

const guchar *      ntd_stm_get_code_table              (NtdStm *stm);

Gets the code table of stm. The table is internally owned and must not be freed or modified.

stm :

a NtdStm

Returns :

the code table array

ntd_stm_get_flash_base ()

gulong              ntd_stm_get_flash_base              (NtdStm *stm);

Gets the base flash address of stm.

stm :

a DspStm instance

Returns :

the base flash address

ntd_stm_get_pid ()

guint               ntd_stm_get_pid                     (NtdStm *stm);

Gets the product id of stm.

stm :

a DspStm instance

Returns :

a product id

ntd_stm_get_version ()

const gchar *       ntd_stm_get_version                 (NtdStm *stm);

Gets the version of stm. This is an informational string.

stm :

a NtdStm

Returns :

the version

ntd_stm_new ()

NtdStm *            ntd_stm_new                         (void);

Creates a new generic NtdStm instance.

Returns :

the newly created object

ntd_stm_new_with_device ()

NtdStm *            ntd_stm_new_with_device             (const gchar *device);

Creates a new default NtdStm instance and binds it to a NtdSerial device automatically configured with sensible defaults.

device :

path to the device to use

Returns :

the newly created object

ntd_stm_set_code_table ()

void                ntd_stm_set_code_table              (NtdStm *stm,
                                                         const guchar *code_table);

Sets a new code table on stm.

code_table must be an array of bytes where every character specifies the code of a command. The command sequence is specified by the NtdStmCommand enum type.

Important

The first byte, instead of representing the code of a NTD_STM_COMMAND_GET comand (always represented by a %'\0' byte), must contain the length of the table, itself included.

stm :

a NtdStm

code_table :

table of command codes

ntd_stm_set_flash_base ()

void                ntd_stm_set_flash_base              (NtdStm *stm,
                                                         gulong flash_base);

Sets the start address of the flash on stm to flash_base.

This number is used to compute the available flash for write operations:

flash(available) = "flash-size" + "flash-base" - "write-base"

stm :

a DspStm instance

flash_base :

the new address

ntd_stm_set_pid ()

void                ntd_stm_set_pid                     (NtdStm *stm,
                                                         guint pid);

Sets the product id of stm to pid. This is a pure informational data that can be used for device specific operations.

stm :

a DspStm instance

pid :

the new product id

ntd_stm_set_version ()

void                ntd_stm_set_version                 (NtdStm *stm,
                                                         const gchar *version);

Sets a new version on stm.

stm :

a NtdStm

version :

version (informational)

Property Details

The "code-table" property

  "code-table"               gpointer              : Read / Write

An array of bytes specifying the codes of the available commands: the first byte, instead of being the GET code (always '\0'), is used to specify the length of the array.


The "flash-base" property

  "flash-base"               gulong                : Read / Write

Starting address of the flash memory.


The "pid" property

  "pid"                      guint                 : Read / Write

Version of the chip, also known as product id.

Default value: 0


The "version" property

  "version"                  gchar*                : Read / Write

Bootloader version.

Default value: NULL