Contains example code to connect the mbed LPC1768 or FRDM-K64F devices to the IBM Internet of Things Cloud service via ethernet.

Dependencies:   C12832 MQTT LM75B MMA7660

Dependents:   MFT_IoT_demo_USB400 IBM_RFID

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) 2012 mbed.org, MIT License
samdanbury 6:37b6d0d56190 2 *
samdanbury 6:37b6d0d56190 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
samdanbury 6:37b6d0d56190 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
samdanbury 6:37b6d0d56190 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
samdanbury 6:37b6d0d56190 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
samdanbury 6:37b6d0d56190 7 * furnished to do so, subject to the following conditions:
samdanbury 6:37b6d0d56190 8 *
samdanbury 6:37b6d0d56190 9 * The above copyright notice and this permission notice shall be included in all copies or
samdanbury 6:37b6d0d56190 10 * substantial portions of the Software.
samdanbury 6:37b6d0d56190 11 *
samdanbury 6:37b6d0d56190 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
samdanbury 6:37b6d0d56190 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
samdanbury 6:37b6d0d56190 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
samdanbury 6:37b6d0d56190 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
samdanbury 6:37b6d0d56190 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
samdanbury 6:37b6d0d56190 17 */
samdanbury 6:37b6d0d56190 18 #ifndef __ARCH_SYS_ARCH_H__
samdanbury 6:37b6d0d56190 19 #define __ARCH_SYS_ARCH_H__
samdanbury 6:37b6d0d56190 20
samdanbury 6:37b6d0d56190 21 #include "lwip/opt.h"
samdanbury 6:37b6d0d56190 22
samdanbury 6:37b6d0d56190 23 #if NO_SYS == 0
samdanbury 6:37b6d0d56190 24 #include "cmsis_os.h"
samdanbury 6:37b6d0d56190 25
samdanbury 6:37b6d0d56190 26 // === SEMAPHORE ===
samdanbury 6:37b6d0d56190 27 typedef struct {
samdanbury 6:37b6d0d56190 28 osSemaphoreId id;
samdanbury 6:37b6d0d56190 29 osSemaphoreDef_t def;
samdanbury 6:37b6d0d56190 30 #ifdef CMSIS_OS_RTX
samdanbury 6:37b6d0d56190 31 uint32_t data[2];
samdanbury 6:37b6d0d56190 32 #endif
samdanbury 6:37b6d0d56190 33 } sys_sem_t;
samdanbury 6:37b6d0d56190 34
samdanbury 6:37b6d0d56190 35 #define sys_sem_valid(x) (((*x).id == NULL) ? 0 : 1)
samdanbury 6:37b6d0d56190 36 #define sys_sem_set_invalid(x) ( (*x).id = NULL)
samdanbury 6:37b6d0d56190 37
samdanbury 6:37b6d0d56190 38 // === MUTEX ===
samdanbury 6:37b6d0d56190 39 typedef struct {
samdanbury 6:37b6d0d56190 40 osMutexId id;
samdanbury 6:37b6d0d56190 41 osMutexDef_t def;
samdanbury 6:37b6d0d56190 42 #ifdef CMSIS_OS_RTX
samdanbury 6:37b6d0d56190 43 int32_t data[3];
samdanbury 6:37b6d0d56190 44 #endif
samdanbury 6:37b6d0d56190 45 } sys_mutex_t;
samdanbury 6:37b6d0d56190 46
samdanbury 6:37b6d0d56190 47 // === MAIL BOX ===
samdanbury 6:37b6d0d56190 48 #define MB_SIZE 8
samdanbury 6:37b6d0d56190 49
samdanbury 6:37b6d0d56190 50 typedef struct {
samdanbury 6:37b6d0d56190 51 osMessageQId id;
samdanbury 6:37b6d0d56190 52 osMessageQDef_t def;
samdanbury 6:37b6d0d56190 53 #ifdef CMSIS_OS_RTX
samdanbury 6:37b6d0d56190 54 uint32_t queue[4+MB_SIZE]; /* The +4 is required for RTX OS_MCB overhead. */
samdanbury 6:37b6d0d56190 55 #endif
samdanbury 6:37b6d0d56190 56 } sys_mbox_t;
samdanbury 6:37b6d0d56190 57
samdanbury 6:37b6d0d56190 58 #define SYS_MBOX_NULL ((uint32_t) NULL)
samdanbury 6:37b6d0d56190 59 #define sys_mbox_valid(x) (((*x).id == NULL) ? 0 : 1 )
samdanbury 6:37b6d0d56190 60 #define sys_mbox_set_invalid(x) ( (*x).id = NULL )
samdanbury 6:37b6d0d56190 61
samdanbury 6:37b6d0d56190 62 #if ((DEFAULT_RAW_RECVMBOX_SIZE) > (MB_SIZE)) || \
samdanbury 6:37b6d0d56190 63 ((DEFAULT_UDP_RECVMBOX_SIZE) > (MB_SIZE)) || \
samdanbury 6:37b6d0d56190 64 ((DEFAULT_TCP_RECVMBOX_SIZE) > (MB_SIZE)) || \
samdanbury 6:37b6d0d56190 65 ((DEFAULT_ACCEPTMBOX_SIZE) > (MB_SIZE)) || \
samdanbury 6:37b6d0d56190 66 ((TCPIP_MBOX_SIZE) > (MB_SIZE))
samdanbury 6:37b6d0d56190 67 # error Mailbox size not supported
samdanbury 6:37b6d0d56190 68 #endif
samdanbury 6:37b6d0d56190 69
samdanbury 6:37b6d0d56190 70 // === THREAD ===
samdanbury 6:37b6d0d56190 71 typedef struct {
samdanbury 6:37b6d0d56190 72 osThreadId id;
samdanbury 6:37b6d0d56190 73 osThreadDef_t def;
samdanbury 6:37b6d0d56190 74 } sys_thread_data_t;
samdanbury 6:37b6d0d56190 75 typedef sys_thread_data_t* sys_thread_t;
samdanbury 6:37b6d0d56190 76
samdanbury 6:37b6d0d56190 77 #define SYS_THREAD_POOL_N 6
samdanbury 6:37b6d0d56190 78 #define SYS_DEFAULT_THREAD_STACK_DEPTH DEFAULT_STACK_SIZE
samdanbury 6:37b6d0d56190 79
samdanbury 6:37b6d0d56190 80 // === PROTECTION ===
samdanbury 6:37b6d0d56190 81 typedef int sys_prot_t;
samdanbury 6:37b6d0d56190 82
samdanbury 6:37b6d0d56190 83 #else
samdanbury 6:37b6d0d56190 84 #ifdef __cplusplus
samdanbury 6:37b6d0d56190 85 extern "C" {
samdanbury 6:37b6d0d56190 86 #endif
samdanbury 6:37b6d0d56190 87
samdanbury 6:37b6d0d56190 88 /** \brief Init systick to 1ms rate
samdanbury 6:37b6d0d56190 89 *
samdanbury 6:37b6d0d56190 90 * This init the systick to 1ms rate. This function is only used in standalone
samdanbury 6:37b6d0d56190 91 * systems.
samdanbury 6:37b6d0d56190 92 */
samdanbury 6:37b6d0d56190 93 void SysTick_Init(void);
samdanbury 6:37b6d0d56190 94
samdanbury 6:37b6d0d56190 95
samdanbury 6:37b6d0d56190 96 /** \brief Get the current systick time in milliSeconds
samdanbury 6:37b6d0d56190 97 *
samdanbury 6:37b6d0d56190 98 * Returns the current systick time in milliSeconds. This function is only
samdanbury 6:37b6d0d56190 99 * used in standalone systems.
samdanbury 6:37b6d0d56190 100 *
samdanbury 6:37b6d0d56190 101 * /returns current systick time in milliSeconds
samdanbury 6:37b6d0d56190 102 */
samdanbury 6:37b6d0d56190 103 uint32_t SysTick_GetMS(void);
samdanbury 6:37b6d0d56190 104
samdanbury 6:37b6d0d56190 105 /** \brief Delay for the specified number of milliSeconds
samdanbury 6:37b6d0d56190 106 *
samdanbury 6:37b6d0d56190 107 * For standalone systems. This function will block for the specified
samdanbury 6:37b6d0d56190 108 * number of milliSconds. For RTOS based systems, this function will delay
samdanbury 6:37b6d0d56190 109 * the task by the specified number of milliSeconds.
samdanbury 6:37b6d0d56190 110 *
samdanbury 6:37b6d0d56190 111 * \param[in] ms Time in milliSeconds to delay
samdanbury 6:37b6d0d56190 112 */
samdanbury 6:37b6d0d56190 113 void osDelay(uint32_t ms);
samdanbury 6:37b6d0d56190 114
samdanbury 6:37b6d0d56190 115 #ifdef __cplusplus
samdanbury 6:37b6d0d56190 116 }
samdanbury 6:37b6d0d56190 117 #endif
samdanbury 6:37b6d0d56190 118 #endif
samdanbury 6:37b6d0d56190 119
samdanbury 6:37b6d0d56190 120 #endif /* __ARCH_SYS_ARCH_H__ */