Synopsis

struct              NtdLpc;
struct              NtdLpcClass;
gboolean            ntd_lpc_answered_0                  (NtdLpc *lpc);
gboolean            ntd_lpc_answered_OK                 (NtdLpc *lpc);
gboolean            ntd_lpc_answered_data               (NtdLpc *lpc,
                                                         gchar **p_data,
                                                         gulong *p_checksum);
gboolean            ntd_lpc_command                     (NtdLpc *lpc,
                                                         const gchar *format,
                                                         ...);
gboolean            ntd_lpc_command_valist              (NtdLpc *lpc,
                                                         const gchar *format,
                                                         va_list var_args);
gpointer            ntd_lpc_decode                      (NtdLpc *lpc,
                                                         guint nbytes);
gboolean            ntd_lpc_encode                      (NtdLpc *lpc,
                                                         gconstpointer data,
                                                         guint nbytes);
guint               ntd_lpc_get_chunk_size              (NtdLpc *lpc);
gsize               ntd_lpc_get_flash_size              (NtdLpc *lpc);
const gchar *       ntd_lpc_get_flash_table             (NtdLpc *lpc);
guint               ntd_lpc_get_frequency               (NtdLpc *lpc);
NtdLpcModel         ntd_lpc_get_model                   (NtdLpc *lpc);
const gchar *       ntd_lpc_get_name                    (NtdLpc *lpc);
gulong              ntd_lpc_get_ram_base                (NtdLpc *lpc);
guint               ntd_lpc_get_ram_size                (NtdLpc *lpc);
gulong              ntd_lpc_get_write_base              (NtdLpc *lpc);
gint                ntd_lpc_map_address                 (NtdLpc *lpc,
                                                         gulong address);
void                ntd_lpc_model_changed               (NtdLpc *lpc);
NtdLpc *            ntd_lpc_new                         (void);
NtdLpc *            ntd_lpc_new_with_device             (const gchar *device);
guint               ntd_lpc_ram_to_flash                (NtdLpc *lpc,
                                                         gulong ram_address,
                                                         gulong flash_address,
                                                         guint size);
gchar *             ntd_lpc_read_line                   (NtdLpc *lpc);
void                ntd_lpc_set_chunk_size              (NtdLpc *lpc,
                                                         guint chunk_size);
void                ntd_lpc_set_flash_table             (NtdLpc *lpc,
                                                         const gchar *flash_table);
void                ntd_lpc_set_frequency               (NtdLpc *lpc,
                                                         guint frequency);
void                ntd_lpc_set_model                   (NtdLpc *lpc,
                                                         NtdLpcModel model);
void                ntd_lpc_set_name                    (NtdLpc *lpc,
                                                         const gchar *name);
void                ntd_lpc_set_ram_base                (NtdLpc *lpc,
                                                         gulong ram_base);
void                ntd_lpc_set_ram_size                (NtdLpc *lpc,
                                                         guint ram_size);
void                ntd_lpc_set_write_base              (NtdLpc *lpc,
                                                         gulong write_base);

Object Hierarchy

  GObject
   +----NtdIsp
         +----NtdLpc

Properties

  "chunk-size"               guint                 : Read / Write
  "flash-table"              gchar*                : Read / Write
  "frequency"                guint                 : Read / Write
  "model"                    NtdLpcModel           : Read / Write
  "name"                     gchar*                : Read / Write
  "ram-base"                 gulong                : Read / Write
  "ram-size"                 guint                 : Read / Write
  "write-base"               gulong                : Read / Write

Signals

  "model-changed"                                  : Run First

Description

To download a program on the LPC the local SRAM must be used as a mid-step. This complicates things a bit because downloading big programs could involve more than one step. The available RAM buffer can be smaller than a flash sector (!) and it is calculated with the following formula:

RAM(available) = "ram-size" + "ram-base" - "write-base"

Another complication is flash sectors don't necessarily have the same size, so the "flash-table" property is provided.

Details

struct NtdLpc

struct NtdLpc;

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


struct NtdLpcClass

struct NtdLpcClass {
};

ntd_lpc_answered_0 ()

gboolean            ntd_lpc_answered_0                  (NtdLpc *lpc);

ntd_lpc_answered_OK ()

gboolean            ntd_lpc_answered_OK                 (NtdLpc *lpc);

ntd_lpc_answered_data ()

gboolean            ntd_lpc_answered_data               (NtdLpc *lpc,
                                                         gchar **p_data,
                                                         gulong *p_checksum);

ntd_lpc_command ()

gboolean            ntd_lpc_command                     (NtdLpc *lpc,
                                                         const gchar *format,
                                                         ...);

ntd_lpc_command_valist ()

gboolean            ntd_lpc_command_valist              (NtdLpc *lpc,
                                                         const gchar *format,
                                                         va_list var_args);

ntd_lpc_decode ()

gpointer            ntd_lpc_decode                      (NtdLpc *lpc,
                                                         guint nbytes);

ntd_lpc_encode ()

gboolean            ntd_lpc_encode                      (NtdLpc *lpc,
                                                         gconstpointer data,
                                                         guint nbytes);

ntd_lpc_get_chunk_size ()

guint               ntd_lpc_get_chunk_size              (NtdLpc *lpc);

Gets the chunk size of lpc.

lpc :

a DspLpc instance

Returns :

the chunk size

ntd_lpc_get_flash_size ()

gsize               ntd_lpc_get_flash_size              (NtdLpc *lpc);

Gets the flash size of lpc.

lpc :

a NtdLpc

Returns :

the flash size, in bytes.

ntd_lpc_get_flash_table ()

const gchar *       ntd_lpc_get_flash_table             (NtdLpc *lpc);

Gets the flash table of lpc. The array is internally owned and must not be freed or modified.

lpc :

a NtdLpc

Returns :

the flash table array

ntd_lpc_get_frequency ()

guint               ntd_lpc_get_frequency               (NtdLpc *lpc);

Gets the current set frequency on lpc.

lpc :

a DspLpc instance

Returns :

the frequency, in kHz

ntd_lpc_get_model ()

NtdLpcModel         ntd_lpc_get_model                   (NtdLpc *lpc);

Gets the model bound to lpc. The model is used to change the behavior of some operations.

lpc :

a NtdLpc

Returns :

the model

ntd_lpc_get_name ()

const gchar *       ntd_lpc_get_name                    (NtdLpc *lpc);

Gets the name bound to lpc. The string is internally owned and must not be freed or modified.

lpc :

a NtdLpc

Returns :

the name bound to this lpc instance

ntd_lpc_get_ram_base ()

gulong              ntd_lpc_get_ram_base                (NtdLpc *lpc);

Gets the base ram address of lpc.

lpc :

a DspLpc instance

Returns :

the base RAM address

ntd_lpc_get_ram_size ()

guint               ntd_lpc_get_ram_size                (NtdLpc *lpc);

Gets the size, in bytes, of the local RAM of lpc.

lpc :

a DspLpc instance

Returns :

the requested size

ntd_lpc_get_write_base ()

gulong              ntd_lpc_get_write_base              (NtdLpc *lpc);

Gets the base write address of lpc.

The returned number identifies the lowest address under which the memory should be considered read-only.

lpc :

a DspLpc instance

Returns :

the base write address or 0 on errors

ntd_lpc_map_address ()

gint                ntd_lpc_map_address                 (NtdLpc *lpc,
                                                         gulong address);

Converts address to a sector number basing the process on the "flash-table" property of lpc.

lpc :

a DspLpc instance

address :

the address to map

Returns :

the sector number address belongs to or -1 if out of range.

ntd_lpc_model_changed ()

void                ntd_lpc_model_changed               (NtdLpc *lpc);

Emits the "model-changed" signal on lpc.

lpc :

a NtdLpc

ntd_lpc_new ()

NtdLpc *            ntd_lpc_new                         (void);

Creates a new generic NtdLpc instance.

Returns :

the newly created object

ntd_lpc_new_with_device ()

NtdLpc *            ntd_lpc_new_with_device             (const gchar *device);

Creates a new default NtdLpc 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_lpc_ram_to_flash ()

guint               ntd_lpc_ram_to_flash                (NtdLpc *lpc,
                                                         gulong ram_address,
                                                         gulong flash_address,
                                                         guint size);

Copies size bytes from ram_address to flash_address.

size should be greather or equal than "chunk-size", if not it is adjusted accordingly. Furthermore, size will be forcibly rounded up to a 256 boundary value.

lpc :

a NtdLpc

ram_address :

source address (must be 4 byte boundary)

flash_address :

destination address (must be 256 byte boundary)

size :

size of the buffer to copy

Returns :

the number of bytes effectively copied, or 0 on errors.

ntd_lpc_read_line ()

gchar *             ntd_lpc_read_line                   (NtdLpc *lpc);

ntd_lpc_set_chunk_size ()

void                ntd_lpc_set_chunk_size              (NtdLpc *lpc,
                                                         guint chunk_size);

Sets the chunk size of lpc to chunk_size.

This option specifies the width (in bytes) of the largest block that can be moved with a single operation by this chip.

lpc :

a DspLpc instance

chunk_size :

the new address

ntd_lpc_set_flash_table ()

void                ntd_lpc_set_flash_table             (NtdLpc *lpc,
                                                         const gchar *flash_table);

Sets a new flash table on lpc.

The flash table is a '\0' terminated array of char (such as normal ASCII text) but where every character specifies the size, in KiB, of the sector at that index. For example, an array such as "\x04\x08\x08" specifies that the lpc chip has 3 flash sectors, the first one of 4KiB and the others of 8KiB.

lpc :

a NtdLpc

flash_table :

name (informational)

ntd_lpc_set_frequency ()

void                ntd_lpc_set_frequency               (NtdLpc *lpc,
                                                         guint frequency);

Sets the frequency of lpc to frequency.

The frequency is required (or only reccomended?) by the communication protocol and its value will be sent (if not 0) after the synchronization step. No idea what it will be used for, though...

lpc :

a DspLpc instance

frequency :

the new frequency

ntd_lpc_set_model ()

void                ntd_lpc_set_model                   (NtdLpc *lpc,
                                                         NtdLpcModel model);

Sets the "model" property of lpc to model. in which case will be treated as an empty string. This operation will emit a "model-changed" signal.

lpc :

a NtdLpc

model :

the new model

ntd_lpc_set_name ()

void                ntd_lpc_set_name                    (NtdLpc *lpc,
                                                         const gchar *name);

Sets a new name on lpc. name can be also NULL, in which case will be treated as an empty string.

lpc :

a NtdLpc

name :

name (informational)

ntd_lpc_set_ram_base ()

void                ntd_lpc_set_ram_base                (NtdLpc *lpc,
                                                         gulong ram_base);

Sets the start address of the RAM on lpc to ram_base.

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

RAM(available) = "ram-size" + "ram-base" - "write-base"

lpc :

a DspLpc instance

ram_base :

the new address

ntd_lpc_set_ram_size ()

void                ntd_lpc_set_ram_size                (NtdLpc *lpc,
                                                         guint ram_size);

Sets the new size of the local RAM of lpc to ram_size. This value is used as base to calculate limit on write operations ("W ..."): check ntd_lpc_set_ram_base() for details.

lpc :

a DspLpc instance

ram_size :

size, in bytes, of the local RAM

ntd_lpc_set_write_base ()

void                ntd_lpc_set_write_base              (NtdLpc *lpc,
                                                         gulong write_base);

Sets the base write address of lpc to write_base.

This number identifies the lowest address under which the memory should be considered read-only.

lpc :

a DspLpc instance

write_base :

the new address

Property Details

The "chunk-size" property

  "chunk-size"               guint                 : Read / Write

Size, in bytes, of the largest chunk that can be copied to flash in a single command.

Default value: 0


The "flash-table" property

  "flash-table"              gchar*                : Read / Write

A \0 terminated array of bytes specifying the size, in KiB, of every flash sector.

Default value: NULL


The "frequency" property

  "frequency"                guint                 : Read / Write

Crystal frequency, in kHz, at which the part is running.

Default value: 14746


The "model" property

  "model"                    NtdLpcModel           : Read / Write

LPC model/variant.

Default value: NTD_LPC_MODEL_UNKNOWN


The "name" property

  "name"                     gchar*                : Read / Write

The informal name of this chip.

Default value: NULL


The "ram-base" property

  "ram-base"                 gulong                : Read / Write

Starting address of the local RAM memory.


The "ram-size" property

  "ram-size"                 guint                 : Read / Write

Size, in bytes, of the local RAM memory.

Default value: 0


The "write-base" property

  "write-base"               gulong                : Read / Write

Base address in the RAM space from which a write operation can start: between "ram-base" and "write-base" the memory should be considered read-only.

Signal Details

The "model-changed" signal

void                user_function                      (NtdLpc  *lpc,
                                                        gpointer user_data)      : Run First

Emitted when "model" property has changed. This will reset the "ram-base" and "write-base" properties to the default values for that model.

lpc :

a NtdLpc

user_data :

user data set when the signal handler was connected.