59 typedef unsigned char u8;
60 typedef signed char s8;
61 typedef unsigned short int u16;
62 typedef signed short int s16;
63 typedef unsigned long int u32;
64 typedef signed long int s32;
65 typedef unsigned long long u64;
66 typedef signed long long s64;
75 typedef unsigned __int8 u8;
77 typedef unsigned __int16 u16;
79 typedef unsigned __int32 u32;
81 typedef unsigned __int64 u64;
84 typedef unsigned char u8;
85 typedef signed char s8;
86 typedef unsigned short int u16;
87 typedef signed short int s16;
88 typedef unsigned int u32;
89 typedef signed int s32;
90 typedef unsigned long long u64;
91 typedef signed long long s64;
94 #define VARIABLE_SIZE 0 103 #elif defined(__C30__) 105 #define MICROCHIP_API 108 typedef unsigned char u8;
109 typedef signed char s8;
110 typedef unsigned short int u16;
111 typedef signed short int s16;
112 typedef unsigned long int u32;
113 typedef signed long int s32;
114 typedef unsigned long long u64;
115 typedef signed long long s64;
116 #define VARIABLE_SIZE 0 122 #elif defined(__APPLE__) 123 #include <TargetConditionals.h> 125 #if TARGET_IPHONE_SIMULATOR 128 #elif TARGET_OS_IPHONE 134 #if defined(__i386__) 136 #elif defined(__x86_64__) 140 #error Unsupported MAC OS X architecture 144 #error Unsupported Apple target 148 typedef unsigned char u8;
149 typedef signed char s8;
150 typedef unsigned short int u16;
151 typedef signed short int s16;
152 typedef unsigned int u32;
153 typedef signed int s32;
155 typedef unsigned long u64;
156 typedef signed long s64;
158 typedef unsigned long long u64;
159 typedef signed long long s64;
161 #define VARIABLE_SIZE 0 170 #elif defined(__linux__) 174 #if defined(__i386__) 179 #elif defined(__x86_64__) 194 typedef uint16_t u16;
196 typedef uint32_t u32;
198 typedef uint64_t u64;
200 #define VARIABLE_SIZE 0 205 #warning UNSUPPORTED ARCHITECTURE, please edit yocto_def.h ! 219 #define INVALID_HASH_IDX -1 220 #define INVALID_BLK_HDL 0 229 #if defined(WINDOWS_API) 230 #if defined(__64BITS__) 242 #define YIO_INVALID 0 249 #define YIO_DEFAULT_USB_TIMEOUT 2000u 250 #define YIO_DEFAULT_TCP_TIMEOUT 20000u 251 #define YIO_1_MINUTE_TCP_TIMEOUT 60000u 252 #define YIO_10_MINUTES_TCP_TIMEOUT 600000u 253 #define YIO_IDLE_TCP_TIMEOUT 5000u 263 #define YIOHDL_SIZE (sizeof(YIOHDL)) 265 #define INVALID_YHANDLE (-1) 267 #define S8(x) ((s8)(x)) 268 #define S16(x) ((s16)(x)) 269 #define S32(x) ((s32)(x)) 270 #define S64(x) ((s64)(x)) 271 #define U8(x) ((u8)(x)) 272 #define U16(x) ((u16)(x)) 273 #define U32(x) ((u32)(x)) 274 #define U64(x) ((u64)(x)) 276 #define U8ADDR(x) ((u8 *)&(x)) 277 #define U16ADDR(x) ((u16 *)&(x)) 279 #define ADDRESSOF(x) (&(x)) 280 #define PTRVAL(x) (*(x)) 282 #if defined(__PIC24FJ256DA206__) 288 #if defined(MICROCHIP_API) || defined(VIRTUAL_HUB) 289 #define YAPI_IN_YDEVICE 292 #define YSTATIC static 298 #ifdef DEBUG_CRITICAL_SECTION 300 #include <winsock2.h> 301 #include <ws2tcpip.h> 326 #define YCS_NB_TRACE 5 330 volatile YCS_STATE state;
332 #if defined(WINDOWS_API) 337 YCS_LOC last_actions[YCS_NB_TRACE];
344 void yDbgInitializeCriticalSection(
const char* fileid,
int lineno, yCRITICAL_SECTION *cs);
345 void yDbgEnterCriticalSection(
const char* fileid,
int lineno, yCRITICAL_SECTION *cs);
346 int yDbgTryEnterCriticalSection(
const char* fileid,
int lineno, yCRITICAL_SECTION *cs);
347 void yDbgLeaveCriticalSection(
const char* fileid,
int lineno, yCRITICAL_SECTION *cs);
348 void yDbgDeleteCriticalSection(
const char* fileid,
int lineno, yCRITICAL_SECTION *cs);
350 #define yInitializeCriticalSection(cs) yDbgInitializeCriticalSection(__FILE_ID__,__LINE__,cs) 351 #define yEnterCriticalSection(cs) yDbgEnterCriticalSection(__FILE_ID__,__LINE__,cs) 352 #define yTryEnterCriticalSection(cs) yDbgTryEnterCriticalSection(__FILE_ID__,__LINE__,cs) 353 #define yLeaveCriticalSection(cs) yDbgLeaveCriticalSection(__FILE_ID__,__LINE__,cs) 354 #define yDeleteCriticalSection(cs) yDbgDeleteCriticalSection(__FILE_ID__,__LINE__,cs) 357 #if defined(MICROCHIP_API) 358 #define yCRITICAL_SECTION u8 359 #define yInitializeCriticalSection(cs) 360 #define yEnterCriticalSection(cs) 361 #define yTryEnterCriticalSection(cs) 1 362 #define yLeaveCriticalSection(cs) 363 #define yDeleteCriticalSection(cs) 394 #define YISERR(retcode) ((retcode) < 0) 397 #define YOCTO_API_VERSION_STR "1.10" 398 #define YOCTO_API_VERSION_BCD 0x0110 400 #define YOCTO_DEFAULT_PORT 4444 401 #define YOCTO_VXI_PORT 4445 402 #define YOCTO_VENDORID 0x24e0 403 #define YOCTO_DEVID_FACTORYBOOT 1 404 #define YOCTO_DEVID_BOOTLOADER 2 405 #define YOCTO_DEVID_HIGHEST 0xfefe 406 #define YAPI_HASH_BUF_SIZE 28 407 #define YOCTO_CALIB_TYPE_OFS 30 410 #define PORTMAPPER_PORT 111 413 #define YOCTO_AKA_YFUNCTION 0 414 #define YOCTO_AKA_YSENSOR 1 415 #define YOCTO_N_BASECLASSES 2 418 #define YOCTO_ERRMSG_LEN 256 419 #define YOCTO_MANUFACTURER_LEN 20 420 #define YOCTO_SERIAL_LEN 20 421 #define YOCTO_BASE_SERIAL_LEN 8 422 #define YOCTO_PRODUCTNAME_LEN 28 423 #define YOCTO_FIRMWARE_LEN 22 424 #define YOCTO_LOGICAL_LEN 20 425 #define YOCTO_FUNCTION_LEN 20 426 #define YOCTO_UNIT_LEN 10 427 #define YOCTO_PUBVAL_SIZE 6 // Size of the data (can be non null terminated) 428 #define YOCTO_PUBVAL_LEN 16 // Temporary storage, >= YOCTO_PUBVAL_SIZE+2 429 #define YOCTO_REPORT_LEN 9 // Max size of a timed report, including isAvg flag 430 #define YOCTO_SERIAL_SEED_SIZE (YOCTO_SERIAL_LEN - YOCTO_BASE_SERIAL_LEN - 1) 433 #define YOCTO_WEBSOCKET_MAGIC "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" 434 #define YOCTO_WEBSOCKET_MAGIC_LEN 36 467 #define USB_PKT_SIZE 64 468 #define YPKT_USB_VERSION_NO_RETRY_BCD 0x0207 469 #define YPKT_USB_VERSION_BCD 0x0208 470 #define TO_SAFE_U16(safe,unsafe) {(safe).low = (unsafe)&0xff; (safe).high=(unsafe)>>8;} 471 #define FROM_SAFE_U16(safe,unsafe) {(unsafe) = (safe).low |((u16)((safe).high)<<8);} 478 #ifndef CPU_BIG_ENDIAN 480 #define YPKTNOMSK (0x7) 488 #define YPKTNOMSK (0x7) 496 #define YPKT_STREAM 0 503 #define USB_CONF_RESET 0 504 #define USB_CONF_START 1 523 #define YSTREAM_EMPTY 0 524 #define YSTREAM_TCP 1 525 #define YSTREAM_TCP_CLOSE 2 526 #define YSTREAM_NOTICE 3 527 #define YSTREAM_REPORT 4 528 #define YSTREAM_META 5 529 #define YSTREAM_REPORT_V2 6 530 #define YSTREAM_NOTICE_V2 7 531 #define YSTREAM_TCP_NOTIF 8 532 #define YSTREAM_TCP_ASYNCCLOSE 9 536 #define NOTIFY_1STBYTE_MAXTINY 63 537 #define NOTIFY_1STBYTE_MINSMALL 128 539 #define NOTIFY_PKT_NAME 0 540 #define NOTIFY_PKT_PRODNAME 1 541 #define NOTIFY_PKT_CHILD 2 542 #define NOTIFY_PKT_FIRMWARE 3 543 #define NOTIFY_PKT_FUNCNAME 4 544 #define NOTIFY_PKT_FUNCVAL 5 545 #define NOTIFY_PKT_STREAMREADY 6 546 #define NOTIFY_PKT_LOG 7 547 #define NOTIFY_PKT_FUNCNAMEYDX 8 548 #define NOTIFY_PKT_PRODINFO 9 550 #define NOTIFY_V2_LEGACY 0 // unused (reserved for compatibility with legacy notifications) 551 #define NOTIFY_V2_6RAWBYTES 1 // largest type: data is always 6 bytes 552 #define NOTIFY_V2_TYPEDDATA 2 // other types: first data byte holds the decoding format 553 #define NOTIFY_V2_FLUSHGROUP 3 // no data associated 557 #define PUBVAL_LEGACY 0 // 0-6 ASCII characters (normally sent as YSTREAM_NOTICE) 558 #define PUBVAL_1RAWBYTE 1 // 1 raw byte (=2 characters) 559 #define PUBVAL_2RAWBYTES 2 // 2 raw bytes (=4 characters) 560 #define PUBVAL_3RAWBYTES 3 // 3 raw bytes (=6 characters) 561 #define PUBVAL_4RAWBYTES 4 // 4 raw bytes (=8 characters) 562 #define PUBVAL_5RAWBYTES 5 // 5 raw bytes (=10 characters) 563 #define PUBVAL_6RAWBYTES 6 // 6 hex bytes (=12 characters) (sent as V2_6RAWBYTES) 564 #define PUBVAL_C_LONG 7 // 32-bit C signed integer 565 #define PUBVAL_C_FLOAT 8 // 32-bit C float 566 #define PUBVAL_YOCTO_FLOAT_E3 9 // 32-bit Yocto fixed-point format (e-3) 574 #pragma warning( push ) 575 #pragma warning( disable : 4200 ) 582 #ifndef CPU_BIG_ENDIAN 597 char pubval[VARIABLE_SIZE];
604 char pubval[VARIABLE_SIZE];
608 #pragma warning( pop ) 672 #define NOTIFY_NETPKT_NAME '0' 673 #define NOTIFY_NETPKT_PRODNAME '1' 674 #define NOTIFY_NETPKT_CHILD '2' 675 #define NOTIFY_NETPKT_FIRMWARE '3' 676 #define NOTIFY_NETPKT_FUNCNAME '4' 677 #define NOTIFY_NETPKT_FUNCVAL '5' 678 #define NOTIFY_NETPKT_STREAMREADY '6' 679 #define NOTIFY_NETPKT_LOG '7' 680 #define NOTIFY_NETPKT_FUNCNAMEYDX '8' 681 #define NOTIFY_NETPKT_PRODINFO '9' 682 #define NOTIFY_NETPKT_FLUSHV2YDX 't' 683 #define NOTIFY_NETPKT_FUNCV2YDX 'u' 684 #define NOTIFY_NETPKT_TIMEV2YDX 'v' 685 #define NOTIFY_NETPKT_DEVLOGYDX 'w' 686 #define NOTIFY_NETPKT_TIMEVALYDX 'x' 687 #define NOTIFY_NETPKT_FUNCVALYDX 'y' 688 #define NOTIFY_NETPKT_TIMEAVGYDX 'z' 689 #define NOTIFY_NETPKT_NOT_SYNC '@' 691 #define NOTIFY_NETPKT_VERSION "01" 692 #define NOTIFY_NETPKT_START "YN01" 693 #define NOTIFY_NETPKT_START_LEN 4 694 #define NOTIFY_NETPKT_STOP '\n' 695 #define NOTIFY_NETPKT_SEP ',' 696 #define NOTIFY_NETPKT_MAX_LEN (NOTIFY_NETPKT_START_LEN+1+YOCTO_SERIAL_LEN+1+YOCTO_FUNCTION_LEN+1+YOCTO_LOGICAL_LEN+1+1) 698 #define NOTIFY_PKT_NAME_LEN (sizeof(Notification_header) + sizeof(Notification_name)) 699 #define NOTIFY_PKT_PRODNAME_LEN (sizeof(Notification_header) + sizeof(Notification_product)) 700 #define NOTIFY_PKT_PRODINFO_LEN (sizeof(Notification_header) + sizeof(Notification_prodinfo)) 701 #define NOTIFY_PKT_CHILD_LEN (sizeof(Notification_header) + sizeof(Notification_child)) 702 #define NOTIFY_PKT_FIRMWARE_LEN (sizeof(Notification_header) + sizeof(Notification_firmware)) 703 #define NOTIFY_PKT_STREAMREADY_LEN (sizeof(Notification_header) + sizeof(u8)) 704 #define NOTIFY_PKT_LOG_LEN (sizeof(Notification_header) + sizeof(u8)) 705 #define NOTIFY_PKT_FUNCNAME_LEN (sizeof(Notification_header) + sizeof(Notification_funcname)) 706 #define NOTIFY_PKT_FUNCVAL_LEN (sizeof(Notification_header) + sizeof(Notification_funcval)) 707 #define NOTIFY_PKT_FUNCNAMEYDX_LEN (sizeof(Notification_header) + sizeof(Notification_funcnameydx)) 708 #define NOTIFY_PKT_TINYVAL_MAXLEN (sizeof(Notification_tiny) + YOCTO_PUBVAL_SIZE) 719 #ifndef CPU_BIG_ENDIAN 737 #ifndef CPU_BIG_ENDIAN 750 #ifndef CPU_BIG_ENDIAN 752 u8 minDiffExtraLen:2;
753 u8 maxDiffExtraLen:2;
757 u8 maxDiffExtraLen:2;
758 u8 minDiffExtraLen:2;
771 #define MAX_ASYNC_TCPCHAN 4 776 #define USB_META_UTCTIME 1 777 #define USB_META_DLFLUSH 2 778 #define USB_META_ACK_D2H_PACKET 3 779 #define USB_META_WS_ANNOUNCE 4 780 #define USB_META_WS_AUTHENTICATION 5 781 #define USB_META_WS_ERROR 6 782 #define USB_META_ACK_UPLOAD 7 784 #define USB_META_UTCTIME_SIZE 5u 785 #define USB_META_DLFLUSH_SIZE 1u 786 #define USB_META_ACK_D2H_PACKET_SIZE 2u 787 #define USB_META_WS_ANNOUNCE_SIZE (8 + YOCTO_SERIAL_LEN) 788 #define USB_META_WS_AUTHENTICATION_SIZE 28u 789 #define USB_META_WS_ERROR_SIZE 4u 790 #define USB_META_ACK_UPLOAD_SIZE 6u 792 #define USB_META_WS_PROTO_V1 1 // adding authentication support 793 #define USB_META_WS_PROTO_V2 2 // adding API packets throttling 795 #define USB_META_WS_AUTH_FLAGS_VALID 1 // set it if the sha1 and nonce are pertinent 796 #define USB_META_WS_AUTH_FLAGS_RW 2 // set it if RW acces are granted 840 #ifdef CPU_BIG_ENDIAN 858 #define YSSDP_PORT 1900 859 #define YSSDP_MCAST_ADDR_STR "239.255.255.250" 860 #define YSSDP_MCAST_ADDR (0xFAFFFFEF) 861 #define YSSDP_URN_YOCTOPUCE "urn:yoctopuce-com:device:hub:1" 874 #define PROG_NOP 0 // nothing to do 875 #define PROG_REBOOT 1 // reset the device 876 #define PROG_ERASE 2 // erase completely the device 877 #define PROG_PROG 3 // program the device 878 #define PROG_VERIF 4 // program the device 879 #define PROG_INFO 5 // get device info 880 #define PROG_INFO_EXT 6 // get extended device info (flash bootloader only) 882 #define MAX_BYTE_IN_PACKET (60) 883 #define MAX_INSTR_IN_PACKET (MAX_BYTE_IN_PACKET/3) 885 #define ERASE_BLOCK_SIZE_INSTR 512 // the minimal erase size in nb instr 886 #define PROGRAM_BLOCK_SIZE_INSTR 64 // the minimal program size in nb instr 888 #define ERASE_BLOCK_SIZE_BADDR (ERASE_BLOCK_SIZE_INSTR*2) 889 #define PROGRAM_BLOCK_SIZE_BADDR (PROGRAM_BLOCK_SIZE_INSTR*2) 896 #ifndef CPU_BIG_ENDIAN 908 #ifndef CPU_BIG_ENDIAN 926 #ifndef CPU_BIG_ENDIAN 934 #ifndef CPU_BIG_ENDIAN 948 #ifndef CPU_BIG_ENDIAN 972 #ifndef CPU_BIG_ENDIAN 973 #define SET_PROG_POS_PAGENO(PKT_EXT, PAGENO, POS) {\ 974 (PKT_EXT).dwordpos_lo = (POS) & 0xff;\ 975 (PKT_EXT).dwordpos_hi = ((POS) >> 8) & 3;\ 976 (PKT_EXT).pageno = (PAGENO) & 0x3fff;} 977 #define GET_PROG_POS_PAGENO(PKT_EXT, PAGENO, POS) {\ 978 POS = (PKT_EXT).dwordpos_lo + ((u32)(PKT_EXT).dwordpos_hi <<8);\ 979 PAGENO = (PKT_EXT).pageno;} 981 #define INTEL_U16(NUM) (NUM) 982 #define INTEL_U32(NUM) (NUM) 984 #define SET_PROG_POS_PAGENO(PKT_EXT, PAGENO, POS) {\ 985 (PKT_EXT).dwordpos_lo = (POS) & 0xff;\ 986 (PKT_EXT).pageno_lo = (PAGENO) & 0xff;\ 987 (PKT_EXT).misc_hi = (((PAGENO) >>8) & 0x3f)+ (((POS) & 0x300) >>2) ;} 988 #define GET_PROG_POS_PAGENO(PKT_EXT, PAGENO, POS) {\ 989 POS = (PKT_EXT).dwordpos_lo + (((u16)(PKT_EXT).misc_hi << 2) & 0x300);\ 990 PAGENO = (PKT_EXT).pageno_lo + (((u16)(PKT_EXT).misc_hi & 0x3f) << 8);} 991 #define INTEL_U16(NUM) ((((NUM) & 0xff00) >> 8) | (((NUM)&0xff) << 8)) 992 #define INTEL_U32(NUM) ((((NUM) >> 24) & 0xff) | (((NUM) << 8) & 0xff0000) | (((NUM) >> 8) & 0xff00) | (((NUM) << 24) & 0xff000000 )) 998 #define START_APPLICATION_SIGN 0 999 #define START_BOOTLOADER_SIGN ('b'| ('T'<<8)) 1000 #define START_AUTOFLASHER_SIGN ('b'| ('F'<<8)) 1020 #define FAMILY_PIC24FJ256DA210 0X41 1021 #define PIC24FJ128DA206 0x08 1022 #define PIC24FJ128DA106 0x09 1023 #define PIC24FJ128DA210 0x0A 1024 #define PIC24FJ128DA110 0x0B 1025 #define PIC24FJ256DA206 0x0C 1026 #define PIC24FJ256DA106 0x0D 1027 #define PIC24FJ256DA210 0x0E 1028 #define PIC24FJ256DA110 0x0F 1031 #define FAMILY_PIC24FJ64GB004 0x42 1032 #define PIC24FJ32GB002 0x03 1033 #define PIC24FJ64GB002 0x07 1034 #define PIC24FJ32GB004 0x0B 1035 #define PIC24FJ64GB004 0x0F 1038 #define JEDEC_SPANSION_4MB 0x16 1039 #define JEDEC_SPANSION_8MB 0x17
Notification_child childserial
void yInitializeCriticalSection(yCRITICAL_SECTION *cs)
#define YOCTO_PRODUCTNAME_LEN
void(* yapiRequestProgressCallback)(void *context, u32 acked, u32 totalbytes)
#define YOCTO_FIRMWARE_LEN
Notification_prodinfo productinfo
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
#define MAX_BYTE_IN_PACKET
Notification_product productname
YSTREAM_Head first_stream
Notification_funydx funInfo
#define YOCTO_PUBVAL_SIZE
#define YOCTO_FUNCTION_LEN
Notification_funcname funcnamenot
#define YOCTO_MANUFACTURER_LEN
Notification_funcnameydx funcnameydxnot
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
Notification_firmware firmwarenot
void(* yapiRequestAsyncCallback)(void *context, const u8 *result, u32 resultlen, int retcode, const char *errmsg)
Notification_small smallpubvalnot
void yDeleteCriticalSection(yCRITICAL_SECTION *cs)
int yTryEnterCriticalSection(yCRITICAL_SECTION *cs)
Notification_name namenot
Notification_tiny tinypubvalnot
Notification_funcval pubvalnot
char Notification_product[YOCTO_PRODUCTNAME_LEN]
#define YOCTO_LOGICAL_LEN
Notification_funydx funInfo