Etherios Cloud Connector very first porting for mbed. Tested in an LPC1768

Etherios Cloud Connector for Embedded v2.1.0.3 library for mbed. Early porting.

This port is centered mainly in the platform code. So it should work properly with the provided examples of send_data, device_request, data_points, RCI and firmware_update (stub implementation, not a real one... yet ;-)). Filesystem is not implemented yet, and some examples might need changes.

To run, it needs the following libraries: - mbed - mbed-rtos - EthernetInterface

Find more information (and the source code!) about Etherios Cloud Connector for Embedded here: http://www.etherios.com/products/devicecloud/support/connector and in: http://www.etherios.com

Committer:
spastor
Date:
Tue Dec 03 13:34:02 2013 +0000
Revision:
0:1c358ea10753
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
spastor 0:1c358ea10753 1 /*
spastor 0:1c358ea10753 2 * Copyright (c) 2013 Digi International Inc.,
spastor 0:1c358ea10753 3 * All rights not expressly granted are reserved.
spastor 0:1c358ea10753 4 *
spastor 0:1c358ea10753 5 * This Source Code Form is subject to the terms of the Mozilla Public
spastor 0:1c358ea10753 6 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
spastor 0:1c358ea10753 7 * You can obtain one at http://mozilla.org/MPL/2.0/.
spastor 0:1c358ea10753 8 *
spastor 0:1c358ea10753 9 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
spastor 0:1c358ea10753 10 * =======================================================================
spastor 0:1c358ea10753 11 */
spastor 0:1c358ea10753 12
spastor 0:1c358ea10753 13 #ifndef BELE_H_
spastor 0:1c358ea10753 14 #define BELE_H_
spastor 0:1c358ea10753 15
spastor 0:1c358ea10753 16 #include "connector_types.h"
spastor 0:1c358ea10753 17
spastor 0:1c358ea10753 18 /*
spastor 0:1c358ea10753 19 * Endian-independent byte-extraction macros
spastor 0:1c358ea10753 20 */
spastor 0:1c358ea10753 21 #define LOW8(x16) ((uint8_t) (x16))
spastor 0:1c358ea10753 22 #define HIGH8(x16) ((uint8_t) (((uint16_t)(x16)) >> 8))
spastor 0:1c358ea10753 23
spastor 0:1c358ea10753 24 #define LOW16(x32) ((uint16_t) (x32))
spastor 0:1c358ea10753 25 #define HIGH16(x32) ((uint16_t) (((uint32_t)(x32)) >> 16))
spastor 0:1c358ea10753 26
spastor 0:1c358ea10753 27 #define BYTE32_3(x32) ((uint8_t) (((uint32_t)(x32)) >> 24))
spastor 0:1c358ea10753 28 #define BYTE32_2(x32) ((uint8_t) (((uint32_t)(x32)) >> 16))
spastor 0:1c358ea10753 29 #define BYTE32_1(x32) ((uint8_t) (((uint32_t)(x32)) >> 8))
spastor 0:1c358ea10753 30 #define BYTE32_0(x32) ((uint8_t) ((uint32_t)(x32)))
spastor 0:1c358ea10753 31
spastor 0:1c358ea10753 32 #if (defined CONNECTOR_HAS_64_BIT_INTEGERS)
spastor 0:1c358ea10753 33 #define LOW32(x64) ((uint32_t) (x64))
spastor 0:1c358ea10753 34 #define HIGH32(x64) ((uint32_t) (((uint64_t)(x64)) >> 32))
spastor 0:1c358ea10753 35
spastor 0:1c358ea10753 36 #define BYTE64_7(x64) ((uint8_t) (((uint64_t)(x64)) >> 56))
spastor 0:1c358ea10753 37 #define BYTE64_6(x64) ((uint8_t) (((uint64_t)(x64)) >> 48))
spastor 0:1c358ea10753 38 #define BYTE64_5(x64) ((uint8_t) (((uint64_t)(x64)) >> 40))
spastor 0:1c358ea10753 39 #define BYTE64_4(x64) ((uint8_t) (((uint64_t)(x64)) >> 32))
spastor 0:1c358ea10753 40 #define BYTE64_3(x64) ((uint8_t) (((uint64_t)(x64)) >> 24))
spastor 0:1c358ea10753 41 #define BYTE64_2(x64) ((uint8_t) (((uint64_t)(x64)) >> 16))
spastor 0:1c358ea10753 42 #define BYTE64_1(x64) ((uint8_t) (((uint64_t)(x64)) >> 8))
spastor 0:1c358ea10753 43 #define BYTE64_0(x64) ((uint8_t) ((uint64_t)(x64)))
spastor 0:1c358ea10753 44
spastor 0:1c358ea10753 45 static void StoreBE64(void * const array, uint64_t const val)
spastor 0:1c358ea10753 46 {
spastor 0:1c358ea10753 47 ((uint8_t *)(array))[0] = BYTE64_7(val);
spastor 0:1c358ea10753 48 ((uint8_t *)(array))[1] = BYTE64_6(val);
spastor 0:1c358ea10753 49 ((uint8_t *)(array))[2] = BYTE64_5(val);
spastor 0:1c358ea10753 50 ((uint8_t *)(array))[3] = BYTE64_4(val);
spastor 0:1c358ea10753 51 ((uint8_t *)(array))[4] = BYTE64_3(val);
spastor 0:1c358ea10753 52 ((uint8_t *)(array))[5] = BYTE64_2(val);
spastor 0:1c358ea10753 53 ((uint8_t *)(array))[6] = BYTE64_1(val);
spastor 0:1c358ea10753 54 ((uint8_t *)(array))[7] = BYTE64_0(val);
spastor 0:1c358ea10753 55 }
spastor 0:1c358ea10753 56 #endif
spastor 0:1c358ea10753 57
spastor 0:1c358ea10753 58 /*
spastor 0:1c358ea10753 59 * Endian-independent multi-byte-creation macros
spastor 0:1c358ea10753 60 */
spastor 0:1c358ea10753 61 #define MAKE16(hi8,lo8) ((uint16_t) (((uint16_t)(((uint16_t) (hi8) ) << 8 )) | ((uint16_t) (lo8))))
spastor 0:1c358ea10753 62 #define MAKE32(hi16,lo16) ((uint32_t) (((uint32_t) (((uint32_t)(hi16)) << 16)) | ((uint32_t)(lo16))))
spastor 0:1c358ea10753 63 #define MAKE64(hi32,lo32) ((uint64_t) (((uint64_t) (((uint32_t)(hi32)) << 32)) | ((uint32_t)(lo32))))
spastor 0:1c358ea10753 64 #define MAKE32_4(b3, b2, b1, b0) MAKE32( MAKE16( b3, b2 ), MAKE16( b1, b0 ))
spastor 0:1c358ea10753 65
spastor 0:1c358ea10753 66 static uint16_t LoadBE16(void const * const array)
spastor 0:1c358ea10753 67 {
spastor 0:1c358ea10753 68 return MAKE16(((uint8_t *)(array))[0], ((uint8_t *)(array))[1]);
spastor 0:1c358ea10753 69 }
spastor 0:1c358ea10753 70
spastor 0:1c358ea10753 71 static uint32_t LoadBE32(void const * const array)
spastor 0:1c358ea10753 72 {
spastor 0:1c358ea10753 73 return MAKE32_4(((uint8_t *)(array))[0], ((uint8_t *)(array))[1], ((uint8_t *)(array))[2], ((uint8_t *)(array))[3]);
spastor 0:1c358ea10753 74 }
spastor 0:1c358ea10753 75
spastor 0:1c358ea10753 76 static void StoreBE16(void * const array, uint16_t const val)
spastor 0:1c358ea10753 77 {
spastor 0:1c358ea10753 78 ((uint8_t *)(array))[0] = HIGH8(val);
spastor 0:1c358ea10753 79 ((uint8_t *)(array))[1] = LOW8(val);
spastor 0:1c358ea10753 80 }
spastor 0:1c358ea10753 81
spastor 0:1c358ea10753 82 static void StoreBE32(void * const array, uint32_t const val)
spastor 0:1c358ea10753 83 {
spastor 0:1c358ea10753 84 ((uint8_t *)(array))[0] = BYTE32_3(val);
spastor 0:1c358ea10753 85 ((uint8_t *)(array))[1] = BYTE32_2(val);
spastor 0:1c358ea10753 86 ((uint8_t *)(array))[2] = BYTE32_1(val);
spastor 0:1c358ea10753 87 ((uint8_t *)(array))[3] = BYTE32_0(val);
spastor 0:1c358ea10753 88 }
spastor 0:1c358ea10753 89
spastor 0:1c358ea10753 90 /*
spastor 0:1c358ea10753 91 * static uint32_t bele_SWAP32(uint32_t const val)
spastor 0:1c358ea10753 92 * {
spastor 0:1c358ea10753 93 * return MAKE32(bele_SWAP16(LOW16(val)), bele_SWAP16(HIGH16(val)));
spastor 0:1c358ea10753 94 * }
spastor 0:1c358ea10753 95 */
spastor 0:1c358ea10753 96
spastor 0:1c358ea10753 97 #if (defined CONNECTOR_LITTLE_ENDIAN)
spastor 0:1c358ea10753 98
spastor 0:1c358ea10753 99 static uint16_t bele_SWAP16(uint16_t const val)
spastor 0:1c358ea10753 100 {
spastor 0:1c358ea10753 101 return MAKE16(LOW8(val), HIGH8(val));
spastor 0:1c358ea10753 102 }
spastor 0:1c358ea10753 103
spastor 0:1c358ea10753 104 #define FROM_LE32(x) (x)
spastor 0:1c358ea10753 105 #define FROM_LE16(x) (x)
spastor 0:1c358ea10753 106
spastor 0:1c358ea10753 107 #define TO_BE32(x) (bele_SWAP32(x))
spastor 0:1c358ea10753 108 #define TO_BE16(x) (bele_SWAP16(x))
spastor 0:1c358ea10753 109 #define FROM_BE32(x) (bele_SWAP32(x))
spastor 0:1c358ea10753 110 #define FROM_BE16(x) (bele_SWAP16(x))
spastor 0:1c358ea10753 111
spastor 0:1c358ea10753 112 #else
spastor 0:1c358ea10753 113
spastor 0:1c358ea10753 114 #define FROM_LE32(x) (bele_SWAP32(x))
spastor 0:1c358ea10753 115 #define FROM_LE16(x) (bele_SWAP16(x))
spastor 0:1c358ea10753 116
spastor 0:1c358ea10753 117 #define TO_BE32(x) (x)
spastor 0:1c358ea10753 118 #define TO_BE16(x) (x)
spastor 0:1c358ea10753 119 #define FROM_BE32(x) (x)
spastor 0:1c358ea10753 120 #define FROM_BE16(x) (x)
spastor 0:1c358ea10753 121
spastor 0:1c358ea10753 122 #endif
spastor 0:1c358ea10753 123
spastor 0:1c358ea10753 124 #endif
spastor 0:1c358ea10753 125