Port to C027 (using AppShield and Ethernet)

Dependencies:   C12832 EthernetInterface LM75B MMA7660 MQTT mbed-rtos mbed

Fork of IBMIoTClientEthernetExample by IBM Watson IoT

Committer:
samdanbury
Date:
Wed Aug 20 12:45:14 2014 +0000
Revision:
6:37b6d0d56190
Code completely changed to improve the structure, flow and memory usage of the application

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samdanbury 6:37b6d0d56190 1 /* Copyright (C) 2013 - Adam Green (https://github.com/adamgreen)
samdanbury 6:37b6d0d56190 2
samdanbury 6:37b6d0d56190 3 Licensed under the Apache License, Version 2.0 (the "License");
samdanbury 6:37b6d0d56190 4 you may not use this file except in compliance with the License.
samdanbury 6:37b6d0d56190 5 You may obtain a copy of the License at
samdanbury 6:37b6d0d56190 6
samdanbury 6:37b6d0d56190 7 http://www.apache.org/licenses/LICENSE-2.0
samdanbury 6:37b6d0d56190 8
samdanbury 6:37b6d0d56190 9 Unless required by applicable law or agreed to in writing, software
samdanbury 6:37b6d0d56190 10 distributed under the License is distributed on an "AS IS" BASIS,
samdanbury 6:37b6d0d56190 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
samdanbury 6:37b6d0d56190 12 See the License for the specific language governing permissions and
samdanbury 6:37b6d0d56190 13 limitations under the License.
samdanbury 6:37b6d0d56190 14 */
samdanbury 6:37b6d0d56190 15 #if defined(TOOLCHAIN_GCC) && defined(__thumb2__)
samdanbury 6:37b6d0d56190 16
samdanbury 6:37b6d0d56190 17 #include <stdio.h>
samdanbury 6:37b6d0d56190 18
samdanbury 6:37b6d0d56190 19
samdanbury 6:37b6d0d56190 20 /* This is a hand written Thumb-2 assembly language version of the
samdanbury 6:37b6d0d56190 21 standard C memcpy() function that can be used by the lwIP networking
samdanbury 6:37b6d0d56190 22 stack to improve its performance. It copies 4 bytes at a time and
samdanbury 6:37b6d0d56190 23 unrolls the loop to perform 4 of these copies per loop iteration.
samdanbury 6:37b6d0d56190 24 */
samdanbury 6:37b6d0d56190 25 __attribute__((naked)) void thumb2_memcpy(void* pDest, const void* pSource, size_t length)
samdanbury 6:37b6d0d56190 26 {
samdanbury 6:37b6d0d56190 27 __asm (
samdanbury 6:37b6d0d56190 28 ".syntax unified\n"
samdanbury 6:37b6d0d56190 29 ".thumb\n"
samdanbury 6:37b6d0d56190 30
samdanbury 6:37b6d0d56190 31 // Copy 16 bytes at a time first.
samdanbury 6:37b6d0d56190 32 " lsrs r3, r2, #4\n"
samdanbury 6:37b6d0d56190 33 " beq.n 2$\n"
samdanbury 6:37b6d0d56190 34 "1$: ldr r12, [r1], #4\n"
samdanbury 6:37b6d0d56190 35 " str r12, [r0], #4\n"
samdanbury 6:37b6d0d56190 36 " ldr r12, [r1], #4\n"
samdanbury 6:37b6d0d56190 37 " str r12, [r0], #4\n"
samdanbury 6:37b6d0d56190 38 " ldr r12, [r1], #4\n"
samdanbury 6:37b6d0d56190 39 " str r12, [r0], #4\n"
samdanbury 6:37b6d0d56190 40 " ldr r12, [r1], #4\n"
samdanbury 6:37b6d0d56190 41 " str r12, [r0], #4\n"
samdanbury 6:37b6d0d56190 42 " subs r3, #1\n"
samdanbury 6:37b6d0d56190 43 " bne 1$\n"
samdanbury 6:37b6d0d56190 44
samdanbury 6:37b6d0d56190 45 // Copy byte by byte for what is left.
samdanbury 6:37b6d0d56190 46 "2$:\n"
samdanbury 6:37b6d0d56190 47 " ands r3, r2, #0xf\n"
samdanbury 6:37b6d0d56190 48 " beq.n 4$\n"
samdanbury 6:37b6d0d56190 49 "3$: ldrb r12, [r1], #1\n"
samdanbury 6:37b6d0d56190 50 " strb r12, [r0], #1\n"
samdanbury 6:37b6d0d56190 51 " subs r3, #1\n"
samdanbury 6:37b6d0d56190 52 " bne 3$\n"
samdanbury 6:37b6d0d56190 53
samdanbury 6:37b6d0d56190 54 // Return to caller.
samdanbury 6:37b6d0d56190 55 "4$: bx lr\n"
samdanbury 6:37b6d0d56190 56 );
samdanbury 6:37b6d0d56190 57 }
samdanbury 6:37b6d0d56190 58
samdanbury 6:37b6d0d56190 59 #endif