Commit 4d9147bd1bced5ce2254e258946557ca9098b9e0

Authored by Imanol-Mikel Barba Sabariego
1 parent 737f88e5

--no commit message

DUREX/Em/DUREX-STUBS.c 0 → 100644
  1 +/**** DO NOT EDIT -- this file has been automatically generated from @emmoco.com.DUREX on 2014-05-14T16:44:10T ****/
  2 +/**** protocolLevel = 13, toolsVersion = 13.4.1.201311121909 ****/
  3 +
  4 +#include "DUREX.h"
  5 +
  6 +#ifdef DUREX_STUBS_ /* enables optional inclusion of application stubs */
  7 +
  8 +/* Copy the function skeletons below into your own application source file */
  9 +
  10 +void DUREX_connectHandler(void) {
  11 + /* TODO: application is now connected */
  12 +}
  13 +
  14 +void DUREX_disconnectHandler(void) {
  15 + /* TODO: application is now disconnected */
  16 +}
  17 +
  18 +void DUREX_numBytes_fetch(DUREX_numBytes_t* output) {
  19 + /* TODO: read resource 'numBytes' into 'output' */
  20 +}
  21 +
  22 +void DUREX_numBytes_store(DUREX_numBytes_t* input) {
  23 + /* TODO: write resource 'numBytes' from 'input' */
  24 +}
  25 +
  26 +void DUREX_data_fetch(DUREX_data_t output) {
  27 + /* TODO: read resource 'data' into 'output' */
  28 +}
  29 +
  30 +void DUREX_data_store(DUREX_data_t input) {
  31 + /* TODO: write resource 'data' from 'input' */
  32 +}
  33 +
  34 +void DUREX_numPackets_fetch(DUREX_numPackets_t* output) {
  35 + /* TODO: read resource 'numPackets' into 'output' */
  36 +}
  37 +
  38 +void DUREX_numPackets_store(DUREX_numPackets_t* input) {
  39 + /* TODO: write resource 'numPackets' from 'input' */
  40 +}
  41 +
  42 +void DUREX_messageAvailable_fetch(DUREX_messageAvailable_t* output) {
  43 + /* TODO: read resource 'messageAvailable' into 'output' */
  44 +}
  45 +
  46 +#endif /* application stubs */
DUREX/Em/DUREX.c 0 → 100644
  1 +/**** DO NOT EDIT -- this file has been automatically generated from @emmoco.com.DUREX on 2014-05-14T16:44:10T ****/
  2 +/**** protocolLevel = 13, toolsVersion = 13.4.1.201311121909 ****/
  3 +
  4 +#include "Em_Message.h"
  5 +#include "DUREX.h"
  6 +
  7 +#ifdef __cplusplus
  8 +extern "C" {
  9 +#endif
  10 +
  11 +#define Em_Message_protocolLevel 13
  12 +
  13 +typedef struct Em_App_Message {
  14 + uint8_t dummy[3];
  15 + uint8_t sot;
  16 + Em_Message_Header hdr;
  17 + uint8_t data[229];
  18 +} Em_App_Message;
  19 +
  20 +const uint8_t Em_App_hash[] = {28, 106, 83, 11, 248, 159, 192, 243, 66, 193, 233, 148, 55, 208, 191, 77, 13, 0, ((sizeof(struct{uint8_t f1; uint16_t f2;}) - sizeof(uint16_t)) << 4) | (sizeof(struct{uint8_t f1; uint32_t f2;}) - sizeof(uint32_t))};
  21 +
  22 +const uint8_t Em_App_build[] = {208, 202, 48, 251, 69, 1, 0, 0};
  23 +
  24 +#define Em_App_APP_RESOURCE_COUNT 4
  25 +#define Em_App_SYS_RESOURCE_COUNT 9
  26 +
  27 +#define Em_App_ACCEPT DUREX_accept
  28 +#define Em_App_ACTIVATEPARAMETERS DUREX_activateParameters
  29 +#define Em_App_BROADCASTOFF DUREX_broadcastOff
  30 +#define Em_App_DISCONNECT DUREX_disconnect
  31 +#define Em_App_PAIRINGON DUREX_pairingOn
  32 +#define Em_App_PAIRINGOFF DUREX_pairingOff
  33 +#define Em_App_RESET DUREX_reset
  34 +#define Em_App_SETDEVICENAME DUREX_setDeviceName
  35 +#define Em_App_START DUREX_start
  36 +
  37 +#define Em_App_CONNECTHANDLER DUREX_connectHandler
  38 +#define Em_App_DISCONNECTHANDLER DUREX_disconnectHandler
  39 +
  40 +#define Em_App_MAX_INDICATOR 2
  41 +
  42 +/* BEGIN common code */
  43 +
  44 +enum {Em_App_IDLE, Em_App_STARTING, Em_App_DISCONNECTED, Em_App_CONNECTED};
  45 +
  46 +typedef struct Em_App_Indicator {
  47 + uint8_t dummy[3];
  48 + uint8_t sot;
  49 + Em_Message_Header hdr;
  50 + uint8_t data[Em_Message_INDSIZE];
  51 +} Em_App_Indicator;
  52 +
  53 +union { uint32_t align; Em_App_Message msg; } Em_App_msg_u;
  54 +union { uint32_t align; Em_App_Indicator ind; } Em_App_ind_u;
  55 +#define Em_App_msg Em_App_msg_u.msg
  56 +#define Em_App_ind Em_App_ind_u.ind
  57 +
  58 +void (*Em_App_pdHdlr)(void);
  59 +
  60 +const uint16_t Em_App_endian = 0x0100;
  61 +
  62 +Em_Message_Size Em_App_recvIdx;
  63 +Em_Message_Size Em_App_recvSize;
  64 +Em_Message_Size Em_App_xmitIdx;
  65 +Em_Message_Size Em_App_xmitSize;
  66 +
  67 +uint8_t Em_App_state = Em_App_IDLE;
  68 +int32_t Em_App_fileIndex = 0;
  69 +uint32_t Em_App_xmitMask = 0;
  70 +
  71 +uint8_t* Em_App_valp;
  72 +uint8_t* Em_App_bufp;
  73 +const char* Em_App_desc;
  74 +
  75 +uint8_t* Em_App_inBuf = (uint8_t*)&Em_App_msg.hdr;
  76 +uint8_t* Em_App_outBuf = 0;
  77 +
  78 +uint8_t* _Em_Message_rxBuf = 0;
  79 +uint8_t _Em_Message_rxCnt = 0;
  80 +
  81 +uint8_t* _Em_Message_txBuf = 0;
  82 +uint8_t _Em_Message_txCnt = 0;
  83 +
  84 +#define Em_App_DEVNAME_LEN 9
  85 +const char* Em_App_devName = 0;
  86 +
  87 +void Em_App_fetchDispatch(void);
  88 +void Em_Message_marshallToBuf(uint8_t* valp, uint8_t* bufp, const char* desc);
  89 +void Em_Message_marshallToVal(uint8_t* valp, uint8_t* bufp, const char* desc);
  90 +void Em_App_storeDispatch(void);
  91 +void Em_App_sendIndicator(Em_Message_ResId indId);
  92 +void Em_App_sendResponse(Em_Message_Kind kind, Em_Message_Size size);
  93 +void Em_App_startIndSend(void);
  94 +void Em_App_startResSend(void);
  95 +void Em_App_sysFetchDispatch(void);
  96 +void Em_App_sysStoreDispatch(void);
  97 +bool Em_App_xmitReady(Em_Message_ResId indId);
  98 +
  99 +void Em_Message_nextXmit(void) {
  100 + uint8_t key = Em_Hal_lock();
  101 + if (Em_App_xmitMask != 0) {
  102 + uint8_t i;
  103 + uint32_t m;
  104 + for (i = 0, m = 0x1; i < Em_App_MAX_INDICATOR; i++, m <<= 1) {
  105 + if (Em_App_xmitMask & m) {
  106 + Em_App_xmitMask &= ~m;
  107 + if (i == 0) {
  108 + Em_App_startResSend();
  109 + }
  110 + else {
  111 + Em_App_sendIndicator(i - 1);
  112 + }
  113 + break;
  114 + }
  115 + }
  116 + }
  117 + Em_Hal_unlock(key);
  118 +}
  119 +
  120 +void Em_Message_restart(void) {
  121 + Em_App_START();
  122 +}
  123 +
  124 +void Em_App_ACCEPT(bool enable) {
  125 + if (Em_App_state == Em_App_CONNECTED) {
  126 + return;
  127 + }
  128 + Em_App_ind.sot = 0;
  129 + Em_App_ind.hdr.kind = Em_Message_ACCEPT;
  130 + Em_App_ind.hdr.size = sizeof (Em_Message_Header);
  131 + Em_App_ind.hdr.resId = enable;
  132 + Em_App_startIndSend();
  133 +}
  134 +
  135 +void Em_App_ACTIVATEPARAMETERS(uint8_t group) {
  136 + if (Em_App_state == Em_App_IDLE || Em_App_state == Em_App_STARTING) {
  137 + return;
  138 + }
  139 + Em_App_ind.sot = 0;
  140 + Em_App_ind.hdr.kind = Em_Message_ACTIVE_PARAMS;
  141 + Em_App_ind.hdr.size = sizeof (Em_Message_Header);
  142 + Em_App_ind.hdr.resId = group;
  143 + Em_App_startIndSend();
  144 +}
  145 +
  146 +void Em_App_BROADCASTOFF(void) {
  147 + Em_App_ind.sot = 0;
  148 + Em_App_ind.hdr.kind = Em_Message_INDICATOR;
  149 + Em_App_ind.hdr.size = sizeof (Em_Message_Header);
  150 + Em_App_ind.hdr.resId = 0;
  151 + Em_App_startIndSend();
  152 +}
  153 +
  154 +void Em_App_DISCONNECT(void) {
  155 + if (Em_App_state != Em_App_CONNECTED) {
  156 + return;
  157 + }
  158 + Em_App_state = Em_App_DISCONNECTED;
  159 + Em_App_ind.sot = 0;
  160 + Em_App_ind.hdr.kind = Em_Message_DISCONNECT;
  161 + Em_App_ind.hdr.size = sizeof (Em_Message_Header);
  162 + Em_App_ind.hdr.resId = 0;
  163 + Em_App_startIndSend();
  164 +}
  165 +
  166 +void Em_Message_dispatch(void) {
  167 + if (Em_App_state == Em_App_IDLE) {
  168 + return;
  169 + }
  170 + switch (Em_App_msg.hdr.kind) {
  171 + case Em_Message_CONNECT:
  172 + Em_App_state = Em_App_CONNECTED;
  173 + Em_App_CONNECTHANDLER();
  174 + break;
  175 + case Em_Message_DISCONNECT:
  176 + Em_App_state = Em_App_DISCONNECTED;
  177 + Em_App_DISCONNECTHANDLER();
  178 + break;
  179 + case Em_Message_PAIRING_DONE:
  180 + if (Em_App_pdHdlr) {
  181 + (*Em_App_pdHdlr)();
  182 + }
  183 + break;
  184 + case Em_Message_FETCH:
  185 + if (Em_App_msg.hdr.resId < 0x80) {
  186 + Em_App_fetchDispatch();
  187 + }
  188 + else {
  189 + Em_App_sysFetchDispatch();
  190 + }
  191 + break;
  192 + case Em_Message_STORE:
  193 + if (Em_App_msg.hdr.resId < 0x80) {
  194 + Em_App_storeDispatch();
  195 + }
  196 + else {
  197 + Em_App_sysStoreDispatch();
  198 + }
  199 + break;
  200 + }
  201 +}
  202 +
  203 +void Em_App_marshallToBuf() {
  204 + char ch;
  205 + while ((ch = *Em_App_desc++)) {
  206 + switch (ch) {
  207 + case '0' : {
  208 + *Em_App_bufp++ = 0;
  209 + break;
  210 + }
  211 + case '1' : {
  212 + *Em_App_bufp++ = *Em_App_valp & 0xFF;
  213 + break;
  214 + }
  215 + case '2' : {
  216 + uint16_t v16 = *(uint16_t*)Em_App_valp;
  217 + *Em_App_bufp++ = v16 & 0xFF;
  218 + *Em_App_bufp++ = (v16 >> 8) & 0xFF;
  219 + break;
  220 + }
  221 + case '4' : {
  222 + if (((uint32_t)Em_App_valp & 0x1)) Em_App_valp++;
  223 + uint32_t v32 = *(uint32_t*)Em_App_valp++;
  224 + *Em_App_bufp++ = v32 & 0xFF;
  225 + *Em_App_bufp++ = (v32 >> 8) & 0xFF;
  226 + *Em_App_bufp++ = (v32 >> 16) & 0xFF;
  227 + *Em_App_bufp++ = (v32 >> 24) & 0xFF;
  228 + break;
  229 + }
  230 + }
  231 + Em_App_valp += 1;
  232 + }
  233 +}
  234 +
  235 +void Em_App_marshallToVal() {
  236 + char ch;
  237 + while ((ch = *Em_App_desc++)) {
  238 + switch (ch) {
  239 + case '0' : {
  240 + *Em_App_valp = 0;
  241 + Em_App_bufp += 1;
  242 + break;
  243 + }
  244 + case '1' : {
  245 + *Em_App_valp = *Em_App_bufp++ & 0xFF;
  246 + break;
  247 + }
  248 + case '2' : {
  249 + uint16_t v16 = *Em_App_bufp++ & 0xFF;
  250 + v16 |= (*Em_App_bufp++ << 8);
  251 + *(uint16_t*)Em_App_valp = v16;
  252 + break;
  253 + }
  254 + case '4' : {
  255 + if (((uint32_t)Em_App_valp & 0x1)) Em_App_valp++;
  256 + uint32_t v32 = (uint32_t)*Em_App_bufp++ & 0xFF;
  257 + v32 |= ((uint32_t)*Em_App_bufp++ << 8);
  258 + v32 |= ((uint32_t)*Em_App_bufp++ << 16);
  259 + v32 |= ((uint32_t)*Em_App_bufp++ << 24);
  260 + *(uint32_t*)Em_App_valp++ = v32;
  261 + break;
  262 + }
  263 + }
  264 + Em_App_valp += 1;
  265 + }
  266 +}
  267 +
  268 +void Em_App_PAIRINGOFF(void(*handler)(void)) {
  269 + Em_App_PAIRINGON(0, handler);
  270 +}
  271 +
  272 +void Em_App_PAIRINGON(uint8_t secs, void(*handler)(void)) {
  273 + if (Em_App_state != Em_App_DISCONNECTED) {
  274 + return;
  275 + }
  276 + Em_App_pdHdlr = handler;
  277 + Em_App_ind.sot = 0;
  278 + Em_App_ind.hdr.kind = Em_Message_PAIRING;
  279 + Em_App_ind.hdr.size = sizeof (Em_Message_Header);
  280 + Em_App_ind.hdr.resId = secs;
  281 + Em_App_startIndSend();
  282 +}
  283 +
  284 +void Em_App_RESET(void) {
  285 + Em_Hal_reset();
  286 + _Em_Message_rxBuf = _Em_Message_txBuf = 0;
  287 + _Em_Message_rxCnt = _Em_Message_txCnt = 0;
  288 + Em_App_recvIdx = Em_App_recvSize = Em_App_xmitIdx = Em_App_xmitSize = 0;
  289 + Em_App_state = Em_App_IDLE;
  290 + Em_App_fileIndex = 0;
  291 + Em_App_xmitMask = 0;
  292 +}
  293 +
  294 +void Em_App_SETDEVICENAME(const char* name) {
  295 + Em_App_devName = name;
  296 +}
  297 +
  298 +void Em_App_START(void) {
  299 + Em_App_RESET();
  300 + Em_App_state = Em_App_STARTING;
  301 +}
  302 +
  303 +void Em_App_sendResponse(Em_Message_Kind kind, Em_Message_Size size) {
  304 + if (Em_App_state != Em_App_IDLE) {
  305 + Em_App_msg.sot = 0;
  306 + Em_App_msg.hdr.kind = kind;
  307 + Em_App_msg.hdr.size = size + sizeof (Em_Message_Header);
  308 + if (Em_App_xmitReady(0)) {
  309 + Em_App_startResSend();
  310 + }
  311 + }
  312 +}
  313 +
  314 +void Em_App_startIndSend(void) {
  315 + Em_App_outBuf = (uint8_t*)&Em_App_ind.sot;
  316 + Em_App_xmitSize = Em_App_ind.hdr.size + 1;
  317 + Em_App_xmitIdx = 0;
  318 + Em_Hal_startSend();
  319 +}
  320 +
  321 +void Em_App_startResSend(void) {
  322 + Em_App_outBuf = (uint8_t*)&Em_App_msg.sot;
  323 + Em_App_xmitSize = Em_App_msg.hdr.size + 1;
  324 + Em_App_xmitIdx = 0;
  325 + Em_Hal_startSend();
  326 +}
  327 +
  328 +void Em_App_sysFetchDispatch(void) {
  329 + uint8_t size = 0;
  330 + int i, j;
  331 + switch (Em_App_msg.hdr.resId) {
  332 + case Em_Message_SYS_SCHEMA_HASH:
  333 + for (i = 0; i < sizeof (Em_App_hash); i++) {
  334 + Em_App_msg.data[i] = Em_App_hash[i];
  335 + }
  336 + Em_App_msg.data[sizeof (Em_App_hash)] = *((uint8_t*)&Em_App_endian);
  337 + size = sizeof (Em_App_hash) + 1;
  338 + break;
  339 + case Em_Message_SYS_MCM_NAME:
  340 + if (Em_App_devName) {
  341 + for (i = 0; i < Em_App_DEVNAME_LEN; i++) {
  342 + if ((Em_App_msg.data[i] = Em_App_devName[i]) == 0) {
  343 + break;
  344 + }
  345 + }
  346 + for (j = i; j < Em_App_DEVNAME_LEN; j++) {
  347 + Em_App_msg.data[j] = 0;
  348 + }
  349 + size = Em_App_DEVNAME_LEN;
  350 + }
  351 + break;
  352 + case Em_Message_SYS_EAP_PROTOCOL_LEVEL:
  353 + *((Em_Message_protocolLevel_t*)Em_App_msg.data) = Em_Message_protocolLevel;
  354 + size = sizeof (Em_Message_protocolLevel_t);
  355 + break;
  356 + case Em_Message_SYS_EAP_BUILD_DATE:
  357 + for (i = 0; i < sizeof (Em_App_build); i++) {
  358 + Em_App_msg.data[i] = Em_App_build[i];
  359 + }
  360 + size = sizeof (Em_App_build);
  361 + break;
  362 + case Em_Message_SYS_RESOURCE_COUNT:
  363 + Em_App_msg.data[0] = Em_App_APP_RESOURCE_COUNT;
  364 + Em_App_msg.data[1] = Em_App_SYS_RESOURCE_COUNT;
  365 + size = 2;
  366 + break;
  367 + }
  368 + Em_App_sendResponse(Em_Message_FETCH_DONE, size);
  369 +}
  370 +
  371 +void Em_App_sysStoreDispatch(void) {
  372 + switch (Em_App_msg.hdr.resId) {
  373 + case Em_Message_SYS_FILE_INDEX_RESET:
  374 + Em_App_fileIndex = 0;
  375 + break;
  376 + }
  377 + Em_App_sendResponse(Em_Message_STORE_DONE, 0);
  378 +}
  379 +
  380 +bool Em_App_xmitReady(Em_Message_ResId indId) {
  381 + uint8_t key = Em_Hal_lock();
  382 + bool res = _Em_Message_txBuf == 0 && Em_App_xmitMask == 0;
  383 + if (!res) {
  384 + Em_App_xmitMask |= (1 << indId);
  385 + }
  386 + Em_Hal_unlock(key);
  387 + return res;
  388 +}
  389 +
  390 +/* END common code */
  391 +
  392 +void Em_App_fetchDispatch(void) {
  393 + uint8_t size = 0;
  394 + switch (Em_App_msg.hdr.resId) {
  395 + case 0: {
  396 + break;
  397 + }
  398 + case 1: {
  399 +#ifdef Em_16BIT
  400 + DUREX_numBytes_t val;
  401 + Em_App_valp = (uint8_t*)&val;
  402 + Em_App_bufp = Em_App_msg.data;
  403 + Em_App_desc = "1";
  404 + DUREX_numBytes_fetch(&val);
  405 + Em_App_marshallToBuf();
  406 +#else
  407 + DUREX_numBytes_fetch((void*)Em_App_msg.data);
  408 +#endif
  409 + size = 1;
  410 + break;
  411 + }
  412 + case 2: {
  413 +#ifdef Em_16BIT
  414 + DUREX_data_t val;
  415 + Em_App_valp = (uint8_t*)&val;
  416 + Em_App_bufp = Em_App_msg.data;
  417 + Em_App_desc = "*\xe5[1]";
  418 + DUREX_data_fetch(&val);
  419 + Em_App_marshallToBuf();
  420 +#else
  421 + DUREX_data_fetch((void*)Em_App_msg.data);
  422 +#endif
  423 + size = 229;
  424 + break;
  425 + }
  426 + case 3: {
  427 +#ifdef Em_16BIT
  428 + DUREX_numPackets_t val;
  429 + Em_App_valp = (uint8_t*)&val;
  430 + Em_App_bufp = Em_App_msg.data;
  431 + Em_App_desc = "1";
  432 + DUREX_numPackets_fetch(&val);
  433 + Em_App_marshallToBuf();
  434 +#else
  435 + DUREX_numPackets_fetch((void*)Em_App_msg.data);
  436 +#endif
  437 + size = 1;
  438 + break;
  439 + }
  440 + case 4: {
  441 +#ifdef Em_16BIT
  442 + DUREX_messageAvailable_t val;
  443 + Em_App_valp = (uint8_t*)&val;
  444 + Em_App_bufp = Em_App_msg.data;
  445 + Em_App_desc = "1";
  446 + DUREX_messageAvailable_fetch(&val);
  447 + Em_App_marshallToBuf();
  448 +#else
  449 + DUREX_messageAvailable_fetch((void*)Em_App_msg.data);
  450 +#endif
  451 + size = 1;
  452 + break;
  453 + }
  454 + }
  455 + Em_App_sendResponse(Em_Message_FETCH_DONE, size);
  456 +}
  457 +
  458 +void Em_App_storeDispatch(void) {
  459 + switch (Em_App_msg.hdr.resId) {
  460 + case 0: {
  461 + break;
  462 + }
  463 + case 1: {
  464 +#ifdef Em_16BIT
  465 + DUREX_numBytes_t val;
  466 + Em_App_valp = (uint8_t*)&val;
  467 + Em_App_bufp = Em_App_msg.data;
  468 + Em_App_desc = "1";
  469 + Em_App_marshallToVal();
  470 + DUREX_numBytes_store(&val);
  471 +#else
  472 + DUREX_numBytes_store((void*)Em_App_msg.data);
  473 +#endif
  474 + break;
  475 + }
  476 + case 2: {
  477 +#ifdef Em_16BIT
  478 + DUREX_data_t val;
  479 + Em_App_valp = (uint8_t*)&val;
  480 + Em_App_bufp = Em_App_msg.data;
  481 + Em_App_desc = "*\xe5[1]";
  482 + Em_App_marshallToVal();
  483 + DUREX_data_store(&val);
  484 +#else
  485 + DUREX_data_store((void*)Em_App_msg.data);
  486 +#endif
  487 + break;
  488 + }
  489 + case 3: {
  490 +#ifdef Em_16BIT
  491 + DUREX_numPackets_t val;
  492 + Em_App_valp = (uint8_t*)&val;
  493 + Em_App_bufp = Em_App_msg.data;
  494 + Em_App_desc = "1";
  495 + Em_App_marshallToVal();
  496 + DUREX_numPackets_store(&val);
  497 +#else
  498 + DUREX_numPackets_store((void*)Em_App_msg.data);
  499 +#endif
  500 + break;
  501 + }
  502 + }
  503 + Em_App_sendResponse(Em_Message_STORE_DONE, 0);
  504 +}
  505 +
  506 +void Em_App_sendIndicator(Em_Message_ResId indId) {
  507 + Em_Message_Size resId = 0;
  508 + Em_Message_Size size = 0;
  509 + switch (indId) {
  510 + case 1: {
  511 +#ifdef Em_16BIT
  512 + DUREX_messageAvailable_t val;
  513 + Em_App_valp = (uint8_t*)&val;
  514 + Em_App_bufp = Em_App_ind.data;
  515 + Em_App_desc = "1";
  516 + DUREX_messageAvailable_fetch(&val);
  517 + Em_App_marshallToBuf();
  518 +#else
  519 + DUREX_messageAvailable_fetch((DUREX_messageAvailable_t*)&Em_App_ind.data);
  520 +#endif
  521 + resId = 4;
  522 + size = 1;
  523 + break;
  524 + }
  525 + }
  526 + Em_App_ind.sot = 0;
  527 + Em_App_ind.hdr.kind = Em_Message_INDICATOR;
  528 + Em_App_ind.hdr.size = sizeof (Em_Message_Header) + size;
  529 + Em_App_ind.hdr.resId = resId;
  530 + Em_App_startIndSend();
  531 +}
  532 +
  533 +void DUREX_messageAvailable_indicate(void) {
  534 + if (Em_App_state == Em_App_CONNECTED && Em_App_xmitReady(1 + 1)) Em_App_sendIndicator(1);
  535 +}
  536 +
  537 +#ifdef __cplusplus
  538 +}
  539 +#endif
  540 +
DUREX/Em/DUREX.h 0 → 100644
  1 +/**** DO NOT EDIT -- this file has been automatically generated from @emmoco.com.DUREX on 2014-05-14T16:44:10T ****/
  2 +/**** protocolLevel = 13, toolsVersion = 13.4.1.201311121909 ****/
  3 +
  4 +#ifndef DUREX__H
  5 +#define DUREX__H
  6 +
  7 +#include "Em_Types.h"
  8 +#include "Em_Message.h"
  9 +
  10 +#ifdef __cplusplus
  11 +extern "C" {
  12 +#endif
  13 +
  14 +/* -------- connection callback functions implemented by the application -------- */
  15 +
  16 +void DUREX_connectHandler(void);
  17 +void DUREX_disconnectHandler(void);
  18 +
  19 +/* -------- resource types defined in the schema -------- */
  20 +
  21 +/* typedef String */
  22 +typedef char DUREX_String[229];
  23 +#define DUREX_String_length 229
  24 +
  25 +/* enum BOOLEAN */
  26 +typedef uint8_t DUREX_BOOLEAN;
  27 +#define DUREX_TRUE 0
  28 +#define DUREX_FALSE 1
  29 +
  30 +/* -------- resource callback functions implemented by the application -------- */
  31 +
  32 +/* resource numBytes */
  33 +typedef uint8_t DUREX_numBytes_t;
  34 +extern void DUREX_numBytes_fetch(DUREX_numBytes_t* output);
  35 +extern void DUREX_numBytes_store(DUREX_numBytes_t* input);
  36 +
  37 +/* resource data */
  38 +typedef DUREX_String DUREX_data_t;
  39 +extern void DUREX_data_fetch(DUREX_data_t output);
  40 +extern void DUREX_data_store(DUREX_data_t input);
  41 +
  42 +/* resource numPackets */
  43 +typedef uint8_t DUREX_numPackets_t;
  44 +extern void DUREX_numPackets_fetch(DUREX_numPackets_t* output);
  45 +extern void DUREX_numPackets_store(DUREX_numPackets_t* input);
  46 +
  47 +/* resource messageAvailable */
  48 +typedef DUREX_BOOLEAN DUREX_messageAvailable_t;
  49 +extern void DUREX_messageAvailable_fetch(DUREX_messageAvailable_t* output);
  50 +extern void DUREX_messageAvailable_indicate(void); /* called by the application */
  51 +
  52 +/* -------- application functions implemented in DUREX.c -------- */
  53 +
  54 +void DUREX_accept(bool enable);
  55 +void DUREX_activateParameters(uint8_t group);
  56 +void DUREX_broadcastOff(void);
  57 +void DUREX_disconnect(void);
  58 +void DUREX_pairingOn(uint8_t secs, void(*handler)(void));
  59 +void DUREX_pairingOff(void(*handler)(void));
  60 +void DUREX_reset(void);
  61 +void DUREX_setDeviceName(const char* name);
  62 +void DUREX_start(void);
  63 +
  64 +#ifdef __cplusplus
  65 +}
  66 +#endif
  67 +
  68 +#endif /* DUREX__H */
DUREX/Em/Em_Message.h 0 → 100644
  1 +#ifndef Em_Message_H_
  2 +#define Em_Message_H_
  3 +
  4 +#include "Em_Types.h"
  5 +
  6 +#ifdef __cplusplus
  7 +extern "C" {
  8 +#endif
  9 +
  10 +/* -------- SRT FUNCTIONS CALLED BY HAL -------- */
  11 +
  12 +static inline bool Em_Message_addByte(uint8_t b);
  13 +extern void Em_Message_dispatch(void);
  14 +static inline bool Em_Message_getByte(uint8_t* bp);
  15 +extern void Em_Message_restart(void);
  16 +static inline bool Em_Message_startRx(void);
  17 +static inline uint8_t Em_Message_startTx(void);
  18 +
  19 +
  20 +/* -------- HAL FUNCTIONS CALLED BY SRT -------- */
  21 +
  22 +extern uint8_t Em_Hal_lock(void);
  23 +extern void Em_Hal_reset(void);
  24 +extern void Em_Hal_startSend(void);
  25 +extern void Em_Hal_unlock(uint8_t key);
  26 +extern void Em_Hal_watchOff(void);
  27 +extern void Em_Hal_watchOn(void);
  28 +
  29 +
  30 +/* -------- MESSAGE FORMAT -------- */
  31 +
  32 +/* protocolLevel #4 */
  33 +#define Em_Message_INDSIZE 4
  34 +
  35 +typedef uint8_t Em_Message_Size;
  36 +typedef uint8_t Em_Message_Kind;
  37 +/* protocolLevel #12 -- split 16-bit resId into <resId, chan> */
  38 +typedef uint8_t Em_Message_ResId;
  39 +typedef uint8_t Em_Message_Chan;
  40 +
  41 +#define Em_Message_NOP 0
  42 +#define Em_Message_FETCH 1
  43 +#define Em_Message_FETCH_DONE 2
  44 +#define Em_Message_STORE 3
  45 +#define Em_Message_STORE_DONE 4
  46 +#define Em_Message_INDICATOR 5
  47 +#define Em_Message_CONNECT 6
  48 +#define Em_Message_DISCONNECT 7
  49 +#define Em_Message_ECHO 8
  50 +/* protocolLevel #3 */
  51 +/* protocolLevel #6 -- rename from BROADCAST to PAIRING */
  52 +#define Em_Message_PAIRING 9
  53 +#define Em_Message_PAIRING_DONE 10
  54 +/* protocolLevel #7 */
  55 +#define Em_Message_OFFLINE 11
  56 +/* protocolLevel #8 */
  57 +#define Em_Message_ACCEPT 12
  58 +/* protocolLevel #13 */
  59 +#define Em_Message_START 13
  60 +#define Em_Message_ACTIVE_PARAMS 14
  61 +
  62 +typedef struct Em_Message_Header {
  63 + Em_Message_Size size;
  64 + Em_Message_Kind kind;
  65 + Em_Message_ResId resId;
  66 + Em_Message_Chan chan;
  67 +} Em_Message_Header;
  68 +
  69 +typedef uint16_t Em_Message_protocolLevel_t;
  70 +
  71 +/* protocolLevel #1 */
  72 +
  73 +/* protocolLevel #10 */
  74 +/* #define Em_Message_SYS_SCHEMA_UUID 0xFF */
  75 +
  76 +#define Em_Message_SYS_MCM_PROTOCOL_LEVEL 0xFE
  77 +#define Em_Message_SYS_EAP_PROTOCOL_LEVEL 0xFD
  78 +#define Em_Message_SYS_EAP_BUILD_DATE 0xFC
  79 +
  80 +/* protocolLevel #2 */
  81 +#define Em_Message_SYS_FILE_INDEX_RESET 0xFB
  82 +
  83 +/* protocolLevel #5 */
  84 +#define Em_Message_SYS_SCHEMA_HASH 0xFA
  85 +
  86 +/* protocolLevel #7 */
  87 +#define Em_Message_SYS_RESOURCE_COUNT 0xF9
  88 +
  89 +/* protocolLevel #9 */
  90 +#define Em_Message_SYS_MOBILE_RSSI 0xF8
  91 +
  92 +/* protocolLevel #11 */
  93 +#define Em_Message_SYS_MCM_DISCONNECT 0xF7
  94 +
  95 +/* protocolLevel #13a */
  96 +#define Em_Message_SYS_MCM_NAME 0xF5
  97 +
  98 +
  99 +/* -------- PRIVATE -------- */
  100 +
  101 +extern void Em_Message_nextXmit(void);
  102 +
  103 +extern uint8_t* Em_App_inBuf;
  104 +extern uint8_t* Em_App_outBuf;
  105 +extern Em_Message_Size Em_App_xmitSize;
  106 +
  107 +extern uint8_t* _Em_Message_rxBuf;
  108 +extern uint8_t _Em_Message_rxCnt;
  109 +
  110 +extern uint8_t* _Em_Message_txBuf;
  111 +extern uint8_t _Em_Message_txCnt;
  112 +
  113 +static inline bool Em_Message_addByte(uint8_t b) {
  114 + if (_Em_Message_rxCnt == 0) {
  115 + if (b == 0) {
  116 + return false;
  117 + }
  118 + _Em_Message_rxCnt = b;
  119 + }
  120 + *_Em_Message_rxBuf++ = b;
  121 + if (--_Em_Message_rxCnt == 0) {
  122 + _Em_Message_rxBuf = 0;
  123 + if (_Em_Message_txBuf == 0) {
  124 + Em_Hal_watchOff();
  125 + }
  126 + return true;
  127 + }
  128 + else {
  129 + return false;
  130 + }
  131 +}
  132 +
  133 +static inline bool Em_Message_getByte(uint8_t* bp) {
  134 + if (_Em_Message_txBuf == 0) {
  135 + return false;
  136 + }
  137 + if (_Em_Message_txCnt == 0) {
  138 + _Em_Message_txCnt = *_Em_Message_txBuf + 1;
  139 + }
  140 + if (--_Em_Message_txCnt > 0) {
  141 + *bp = *_Em_Message_txBuf++;
  142 + return true;
  143 + }
  144 + else {
  145 + _Em_Message_txBuf = 0;
  146 + Em_App_xmitSize = 0;
  147 + Em_Message_nextXmit();
  148 + if (_Em_Message_rxBuf == 0) {
  149 + Em_Hal_watchOff();
  150 + }
  151 + return false;
  152 + }
  153 +}
  154 +
  155 +static inline bool Em_Message_startRx(void) {
  156 + if (_Em_Message_rxBuf == 0) {
  157 + _Em_Message_rxBuf = Em_App_inBuf;
  158 + if (_Em_Message_txBuf == 0) {
  159 + Em_Hal_watchOn();
  160 + }
  161 + return true;
  162 + }
  163 + else {
  164 + return false;
  165 + }
  166 +}
  167 +
  168 +static inline uint8_t Em_Message_startTx(void) {
  169 + _Em_Message_txBuf = Em_App_outBuf + 1;
  170 + _Em_Message_txCnt = 0;
  171 + if (_Em_Message_rxBuf == 0) {
  172 + Em_Hal_watchOn();
  173 + }
  174 + return 0;
  175 +}
  176 +
  177 +
  178 +#ifdef __cplusplus
  179 +}
  180 +#endif
  181 +
  182 +#endif /*Em_Message_H_*/
DUREX/Em/Em_Types.h 0 → 100644
  1 +#ifndef Em_Types_H_
  2 +#define Em_Types_H_
  3 +
  4 +#ifndef Em_NOSTDBOOL
  5 +#include <stdbool.h>
  6 +#endif
  7 +
  8 +#ifndef Em_NOSTDINT
  9 +#include <stdint.h>
  10 +#endif
  11 +
  12 +#ifdef Em_16BIT
  13 +typedef signed char int8_t;
  14 +typedef unsigned char uint8_t;
  15 +#endif
  16 +
  17 +#endif /*Em_Types_H_*/
DUREX/Em/durex.json 0 → 100644
  1 +{
  2 + "resources": {
  3 + "$eapProtocolLevel": {
  4 + "id": -3,
  5 + "align": 2,
  6 + "attributes": {"readonly": true},
  7 + "type": "u2",
  8 + "access": "r",
  9 + "size": 2
  10 + },
  11 + "numBytes": {
  12 + "id": 1,
  13 + "align": 1,
  14 + "attributes": {},
  15 + "type": "u1",
  16 + "access": "rw",
  17 + "size": 1
  18 + },
  19 + "data": {
  20 + "id": 2,
  21 + "align": 1,
  22 + "attributes": {},
  23 + "type": "C:229",
  24 + "access": "rw",
  25 + "size": 229
  26 + },
  27 + "$activeGroup": {
  28 + "id": -10,
  29 + "align": 1,
  30 + "pack": 1,
  31 + "attributes": {"readwrite": true},
  32 + "type": "E:system@emmoco.com.System/ParameterGroup",
  33 + "access": "rw",
  34 + "size": 1
  35 + },
  36 + "$mcmDisconnect": {
  37 + "id": -9,
  38 + "align": 1,
  39 + "attributes": {"writeonly": true},
  40 + "type": "u1",
  41 + "access": "w",
  42 + "size": 1
  43 + },
  44 + "$eapBuildDate": {
  45 + "dim": 8,
  46 + "id": -4,
  47 + "align": 1,
  48 + "attributes": {"readonly": true},
  49 + "type": "A8:u1",
  50 + "access": "r",
  51 + "size": 8
  52 + },
  53 + "numPackets": {
  54 + "id": 3,
  55 + "align": 1,
  56 + "attributes": {},
  57 + "type": "u1",
  58 + "access": "rw",
  59 + "size": 1
  60 + },
  61 + "$resourceCount": {
  62 + "id": -7,
  63 + "align": 1,
  64 + "attributes": {"readonly": true},
  65 + "type": "S:system@emmoco.com.System/ResourceCount",
  66 + "access": "r",
  67 + "size": 2
  68 + },
  69 + "$schemaHash": {
  70 + "dim": 20,
  71 + "id": -6,
  72 + "align": 1,
  73 + "attributes": {"readonly": true},
  74 + "type": "A20:u1",
  75 + "access": "r",
  76 + "size": 20
  77 + },
  78 + "messageAvailable": {
  79 + "id": 4,
  80 + "align": 1,
  81 + "pack": 1,
  82 + "attributes": {"indicator": true},
  83 + "type": "E:@emmoco.com.DUREX/BOOLEAN",
  84 + "access": "ir",
  85 + "size": 1
  86 + },
  87 + "$mcmProtocolLevel": {
  88 + "id": -2,
  89 + "align": 2,
  90 + "attributes": {"readonly": true},
  91 + "type": "u2",
  92 + "access": "r",
  93 + "size": 2
  94 + },
  95 + "$mobileRssi": {
  96 + "id": -8,
  97 + "align": 1,
  98 + "attributes": {"readonly": true},
  99 + "type": "i1",
  100 + "access": "r",
  101 + "size": 1
  102 + },
  103 + "$fileIndexReset": {
  104 + "id": -5,
  105 + "align": 2,
  106 + "attributes": {"writeonly": true},
  107 + "type": "i2",
  108 + "access": "w",
  109 + "size": 2
  110 + }
  111 + },
  112 + "resourceNamesSys": [
  113 + "$activeGroup",
  114 + "$eapBuildDate",
  115 + "$eapProtocolLevel",
  116 + "$fileIndexReset",
  117 + "$mcmDisconnect",
  118 + "$mcmProtocolLevel",
  119 + "$mobileRssi",
  120 + "$resourceCount",
  121 + "$schemaHash"
  122 + ],
  123 + "manifest": {
  124 + "protocolLevel": 13,
  125 + "hash": [
  126 + 28,
  127 + 106,
  128 + 83,
  129 + 11,
  130 + 248,
  131 + 159,
  132 + 192,
  133 + 243,
  134 + 66,
  135 + 193,
  136 + 233,
  137 + 148,
  138 + 55,
  139 + 208,
  140 + 191,
  141 + 77
  142 + ],
  143 + "toolVersion": "13.4.1.201311121909",
  144 + "name": "DUREX",
  145 + "$$md5": "1c6a530bf89fc0f342c1e99437d0bf4d",
  146 + "build": [
  147 + 208,
  148 + 202,
  149 + 48,
  150 + 251,
  151 + 69,
  152 + 1,
  153 + 0,
  154 + 0
  155 + ],
  156 + "date": "2014-05-14T16:44:10T",
  157 + "maxAlign": 2,
  158 + "maxSize": 229,
  159 + "version": "1.0.0"
  160 + },
  161 + "resourceNames": [
  162 + "numBytes",
  163 + "data",
  164 + "numPackets",
  165 + "messageAvailable",
  166 + "$mcmProtocolLevel",
  167 + "$eapProtocolLevel",
  168 + "$eapBuildDate",
  169 + "$fileIndexReset",
  170 + "$schemaHash",
  171 + "$resourceCount",
  172 + "$mobileRssi",
  173 + "$mcmDisconnect",
  174 + "$activeGroup"
  175 + ],
  176 + "attributes": {
  177 + "description": "",
  178 + "version": "1.0.0"
  179 + },
  180 + "resourceNamesApp": [
  181 + "numBytes",
  182 + "data",
  183 + "numPackets",
  184 + "messageAvailable"
  185 + ],
  186 + "types": {
  187 + "system@emmoco.com.System/ResourceCount": {
  188 + "packed": false,
  189 + "align": 1,
  190 + "type": "S:system@emmoco.com.System/ResourceCount",
  191 + "size": 2,
  192 + "fields": [
  193 + {
  194 + "pad": 0,
  195 + "align": 1,
  196 + "name": "app",
  197 + "type": "u1",
  198 + "size": 1
  199 + },
  200 + {
  201 + "pad": 0,
  202 + "align": 1,
  203 + "name": "sys",
  204 + "type": "u1",
  205 + "size": 1
  206 + }
  207 + ]
  208 + },
  209 + "std:i2": {
  210 + "align": 2,
  211 + "size": 2
  212 + },
  213 + "std:i1": {
  214 + "align": 1,
  215 + "size": 1
  216 + },
  217 + "std:u1": {
  218 + "align": 1,
  219 + "size": 1
  220 + },
  221 + "@emmoco.com.DUREX/BOOLEAN": {
  222 + "values": [
  223 + "TRUE",
  224 + "FALSE"
  225 + ],
  226 + "align": 1,
  227 + "pack": 1,
  228 + "type": "E:@emmoco.com.DUREX/BOOLEAN",
  229 + "size": 1
  230 + },
  231 + "system@emmoco.com.System/ParameterGroup": {
  232 + "values": [
  233 + "GROUP_A",
  234 + "GROUP_B"
  235 + ],
  236 + "align": 1,
  237 + "pack": 1,
  238 + "type": "E:system@emmoco.com.System/ParameterGroup",
  239 + "size": 1
  240 + },
  241 + "std:u2": {
  242 + "align": 2,
  243 + "size": 2
  244 + }
  245 + },
  246 + "imports": {"@emmoco.com.DUREX": true}
  247 +}
0 \ No newline at end of file 248 \ No newline at end of file
DUREX/Schema-Imports/system@emmoco.com/System.ems 0 → 100644
  1 +owner = "system@emmoco.com"
  2 +
  3 +schema System {
  4 +
  5 + // protocolLevel #13
  6 +
  7 + enum ParameterGroup {
  8 + GROUP_A, GROUP_B
  9 + }
  10 +
  11 + // protocolLevel #1
  12 +
  13 + uint8 $schemaUuid[16] { // protocolLevel #10 -- invisible to applications
  14 + readonly
  15 + }
  16 +
  17 + uint16 $mcmProtocolLevel {
  18 + readonly
  19 + }
  20 +
  21 + uint16 $eapProtocolLevel {
  22 + readonly
  23 + }
  24 +
  25 + uint8 $eapBuildDate[8] { // protocolLevel #5 -- rename from $eapBuildNumber
  26 + readonly
  27 + }
  28 +
  29 + // protocolLevel #2
  30 +
  31 + int16 $fileIndexReset {
  32 + writeonly
  33 + }
  34 +
  35 + // protocolLevel #5
  36 +
  37 + // protocolLevel #12 -- increase size to 20
  38 +
  39 + uint8 $schemaHash[20] {
  40 + readonly
  41 + }
  42 +
  43 + // protocolLevel #7
  44 +
  45 + struct ResourceCount {
  46 + uint8 app
  47 + uint8 sys
  48 + }
  49 +
  50 + ResourceCount $resourceCount {
  51 + readonly
  52 + }
  53 +
  54 + // protocolLevel #9
  55 +
  56 + int8 $mobileRssi {
  57 + readonly
  58 + }
  59 +
  60 + // protocolLevel #11
  61 +
  62 + uint8 $mcmDisconnect {
  63 + writeonly
  64 + }
  65 +
  66 + // protocolLevel #13
  67 +
  68 + ParameterGroup $activeGroup {
  69 + readwrite
  70 + }
  71 +
  72 +}
DUREXLaunchpad/.externalToolBuilders/DUREX LaunchPad Builder.launch 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 +<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
  3 +<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
  4 +<mapAttribute key="org.eclipse.debug.core.environmentVariables">
  5 +<mapEntry key="PATH" value="${eclipse_home}/emmoco/msptools/bin${system_property:path.separator}${env_var:PATH}"/>
  6 +</mapAttribute>
  7 +<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
  8 +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;resources&gt;&#10;&lt;item path=&quot;/TesterLaunchPad/main.c&quot; type=&quot;1&quot;/&gt;&#10;&lt;item path=&quot;/TesterLaunchPad/main.out&quot; type=&quot;1&quot;/&gt;&#10;&lt;item path=&quot;/TesterLaunchPad/makefile&quot; type=&quot;1&quot;/&gt;&#10;&lt;item path=&quot;/TesterSchema/out/Tester.h&quot; type=&quot;1&quot;/&gt;&#10;&lt;item path=&quot;/TesterSchema/schema.ems&quot; type=&quot;1&quot;/&gt;&#10;&lt;item path=&quot;/CommonLaunchPad&quot; type=&quot;4&quot;/&gt;&#10;&lt;/resources&gt;}"/>
  9 +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${eclipse_home}/emmoco/msptools/bin/gmake${exe_ext}"/>
  10 +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
  11 +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="all COMMON=${project_loc:/CommonLaunchPad} SCHEMA=${project_loc:/DUREX}"/>
  12 +<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
  13 +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${project_loc}"/>
  14 +</launchConfiguration>
DUREXLaunchpad/.externalToolBuilders/DUREX LaunchPad Cleaner.launch 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 +<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
  3 +<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
  4 +<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
  5 +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${eclipse_home}/emmoco/msptools/bin/gmake${exe_ext}"/>
  6 +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="clean"/>
  7 +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="local-clean COMMON=${project_loc:/CommonLaunchPad}"/>
  8 +<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
  9 +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${project_loc}"/>
  10 +</launchConfiguration>