sdk/swilib
Kirill Zhumarin 90a894d038
Some checks failed
CI / deploy (push) Failing after 16m48s
Experimental SG patterns
2026-11-25 18:05:31 +03:00
..
include Update docs 2026-11-25 06:13:54 +03:00
patterns
tools Enable BT/LMAN/ENIP/socket declarations for all NewSGOLD, remove my library tools from swilib. 2026-11-16 08:34:21 +02:00
config.toml Corrent swilib functions definitions 2026-10-26 05:02:18 +03:00
Doxyfile
DoxygenLayout.xml
main.c
patterns.toml Experimental SG patterns 2026-11-25 18:05:31 +03:00
README.md Enable BT/LMAN/ENIP/socket declarations for all NewSGOLD, remove my library tools from swilib. 2026-11-16 08:34:21 +02:00

SWILIB - functions from the firmware

Documentation by platforms:

  • SG - SL65, SK65, C65, CX70, ...
  • X75 - CX75, M75, CF75, ...
  • NSG - C81, S75, SL75, S68, ...
  • ELKA - E71, EL71, ...

Note: Functions across platforms are mostly the same, but some structures have different memory layout.

How add new function?

  1. Fork this repository.
  2. Choose right category in include/swilib/*.h
  3. Add function definition to this file, commit changes, send PR.

Format of the function definition:

/**
 * Write data to a file.
 * @param fd			file descriptor
 * @param buffer		pointer to a buffer with data to be written
 * @param length		maximum size for write
 * @param[out] err		error code
 * @return count of written bytes or error (< 0)
 * */ // <--- Short documentation in Doxygen format
__swi_begin(0x00C) // <-- swi number for IAR
int sys_write(int fd, const void *buffer, int length, uint32_t *err) // <-- function definition
__swi_end(0x00C, sys_write, (fd, buffer, length, err)); // <-- swi number for GCC and others

Format of the variadic function definition:

/**
 * Send message to the GBS event processor.
 * You can pass up to 3 additional parameters (submsg, data0, data1 - see #GBS_MSG).
 * @param cepid		destination CEPID.
 * @param msg		ID of the message
 */ // <--- Short documentation in Doxygen format
__swi_variadic_begin(0x100) // <-- swi number for IAR
void GBS_SendMessage(int cepid, int msg, ...) // <-- function definition
__swi_variadic_end(0x100, GBS_SendMessage, cepid, msg); // <-- swi number and fixed arguments for GCC

Macroses:

  • __swi_begin(swi_num) - macros for IAR support
    • swi_num - SWI number
  • __swi_end(swi_num, function_name, function_arguments) - macros for GCC support
    • swi_num - SWI number
    • function_name - name of the function
    • function_arguments - list of the function arguments in braces ()
  • __swi_variadic_begin(swi_num) - variadic function declaration start
    • swi_num - SWI number
  • __swi_variadic_end(swi_num, function_name, fixed_arguments...) - variadic function declaration end
    • swi_num - SWI number
    • function_name - name of the function
    • fixed_arguments - named arguments before ...