Update revision to use TI's mqtt and Freertos.

Dependencies:   mbed client server

Fork of cc3100_Test_mqtt_CM3 by David Fletcher

Committer:
dflet
Date:
Thu Sep 03 14:02:37 2015 +0000
Revision:
3:a8c249046181
SPI Mode change 1 to 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 3:a8c249046181 1 /*
dflet 3:a8c249046181 2 FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.
dflet 3:a8c249046181 3 All rights reserved
dflet 3:a8c249046181 4
dflet 3:a8c249046181 5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
dflet 3:a8c249046181 6
dflet 3:a8c249046181 7 This file is part of the FreeRTOS distribution.
dflet 3:a8c249046181 8
dflet 3:a8c249046181 9 FreeRTOS is free software; you can redistribute it and/or modify it under
dflet 3:a8c249046181 10 the terms of the GNU General Public License (version 2) as published by the
dflet 3:a8c249046181 11 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
dflet 3:a8c249046181 12
dflet 3:a8c249046181 13 ***************************************************************************
dflet 3:a8c249046181 14 >>! NOTE: The modification to the GPL is included to allow you to !<<
dflet 3:a8c249046181 15 >>! distribute a combined work that includes FreeRTOS without being !<<
dflet 3:a8c249046181 16 >>! obliged to provide the source code for proprietary components !<<
dflet 3:a8c249046181 17 >>! outside of the FreeRTOS kernel. !<<
dflet 3:a8c249046181 18 ***************************************************************************
dflet 3:a8c249046181 19
dflet 3:a8c249046181 20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
dflet 3:a8c249046181 21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dflet 3:a8c249046181 22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
dflet 3:a8c249046181 23 link: http://www.freertos.org/a00114.html
dflet 3:a8c249046181 24
dflet 3:a8c249046181 25 ***************************************************************************
dflet 3:a8c249046181 26 * *
dflet 3:a8c249046181 27 * FreeRTOS provides completely free yet professionally developed, *
dflet 3:a8c249046181 28 * robust, strictly quality controlled, supported, and cross *
dflet 3:a8c249046181 29 * platform software that is more than just the market leader, it *
dflet 3:a8c249046181 30 * is the industry's de facto standard. *
dflet 3:a8c249046181 31 * *
dflet 3:a8c249046181 32 * Help yourself get started quickly while simultaneously helping *
dflet 3:a8c249046181 33 * to support the FreeRTOS project by purchasing a FreeRTOS *
dflet 3:a8c249046181 34 * tutorial book, reference manual, or both: *
dflet 3:a8c249046181 35 * http://www.FreeRTOS.org/Documentation *
dflet 3:a8c249046181 36 * *
dflet 3:a8c249046181 37 ***************************************************************************
dflet 3:a8c249046181 38
dflet 3:a8c249046181 39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
dflet 3:a8c249046181 40 the FAQ page "My application does not run, what could be wrong?". Have you
dflet 3:a8c249046181 41 defined configASSERT()?
dflet 3:a8c249046181 42
dflet 3:a8c249046181 43 http://www.FreeRTOS.org/support - In return for receiving this top quality
dflet 3:a8c249046181 44 embedded software for free we request you assist our global community by
dflet 3:a8c249046181 45 participating in the support forum.
dflet 3:a8c249046181 46
dflet 3:a8c249046181 47 http://www.FreeRTOS.org/training - Investing in training allows your team to
dflet 3:a8c249046181 48 be as productive as possible as early as possible. Now you can receive
dflet 3:a8c249046181 49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
dflet 3:a8c249046181 50 Ltd, and the world's leading authority on the world's leading RTOS.
dflet 3:a8c249046181 51
dflet 3:a8c249046181 52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
dflet 3:a8c249046181 53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
dflet 3:a8c249046181 54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
dflet 3:a8c249046181 55
dflet 3:a8c249046181 56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
dflet 3:a8c249046181 57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
dflet 3:a8c249046181 58
dflet 3:a8c249046181 59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
dflet 3:a8c249046181 60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
dflet 3:a8c249046181 61 licenses offer ticketed support, indemnification and commercial middleware.
dflet 3:a8c249046181 62
dflet 3:a8c249046181 63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
dflet 3:a8c249046181 64 engineered and independently SIL3 certified version for use in safety and
dflet 3:a8c249046181 65 mission critical applications that require provable dependability.
dflet 3:a8c249046181 66
dflet 3:a8c249046181 67 1 tab == 4 spaces!
dflet 3:a8c249046181 68 */
dflet 3:a8c249046181 69
dflet 3:a8c249046181 70
dflet 3:a8c249046181 71 #include <stdlib.h>
dflet 3:a8c249046181 72 #include "FreeRTOS.h"
dflet 3:a8c249046181 73 #include "list.h"
dflet 3:a8c249046181 74
dflet 3:a8c249046181 75 /*-----------------------------------------------------------
dflet 3:a8c249046181 76 * PUBLIC LIST API documented in list.h
dflet 3:a8c249046181 77 *----------------------------------------------------------*/
dflet 3:a8c249046181 78
dflet 3:a8c249046181 79 void vListInitialise( List_t * const pxList )
dflet 3:a8c249046181 80 {
dflet 3:a8c249046181 81 /* The list structure contains a list item which is used to mark the
dflet 3:a8c249046181 82 end of the list. To initialise the list the list end is inserted
dflet 3:a8c249046181 83 as the only list entry. */
dflet 3:a8c249046181 84 pxList->pxIndex = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
dflet 3:a8c249046181 85
dflet 3:a8c249046181 86 /* The list end value is the highest possible value in the list to
dflet 3:a8c249046181 87 ensure it remains at the end of the list. */
dflet 3:a8c249046181 88 pxList->xListEnd.xItemValue = portMAX_DELAY;
dflet 3:a8c249046181 89
dflet 3:a8c249046181 90 /* The list end next and previous pointers point to itself so we know
dflet 3:a8c249046181 91 when the list is empty. */
dflet 3:a8c249046181 92 pxList->xListEnd.pxNext = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
dflet 3:a8c249046181 93 pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd );/*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
dflet 3:a8c249046181 94
dflet 3:a8c249046181 95 pxList->uxNumberOfItems = ( UBaseType_t ) 0U;
dflet 3:a8c249046181 96
dflet 3:a8c249046181 97 /* Write known values into the list if
dflet 3:a8c249046181 98 configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
dflet 3:a8c249046181 99 listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList );
dflet 3:a8c249046181 100 listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList );
dflet 3:a8c249046181 101 }
dflet 3:a8c249046181 102 /*-----------------------------------------------------------*/
dflet 3:a8c249046181 103
dflet 3:a8c249046181 104 void vListInitialiseItem( ListItem_t * const pxItem )
dflet 3:a8c249046181 105 {
dflet 3:a8c249046181 106 /* Make sure the list item is not recorded as being on a list. */
dflet 3:a8c249046181 107 pxItem->pvContainer = NULL;
dflet 3:a8c249046181 108
dflet 3:a8c249046181 109 /* Write known values into the list item if
dflet 3:a8c249046181 110 configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
dflet 3:a8c249046181 111 listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem );
dflet 3:a8c249046181 112 listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem );
dflet 3:a8c249046181 113 }
dflet 3:a8c249046181 114 /*-----------------------------------------------------------*/
dflet 3:a8c249046181 115
dflet 3:a8c249046181 116 void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem )
dflet 3:a8c249046181 117 {
dflet 3:a8c249046181 118 ListItem_t * const pxIndex = pxList->pxIndex;
dflet 3:a8c249046181 119
dflet 3:a8c249046181 120 /* Only effective when configASSERT() is also defined, these tests may catch
dflet 3:a8c249046181 121 the list data structures being overwritten in memory. They will not catch
dflet 3:a8c249046181 122 data errors caused by incorrect configuration or use of FreeRTOS. */
dflet 3:a8c249046181 123 listTEST_LIST_INTEGRITY( pxList );
dflet 3:a8c249046181 124 listTEST_LIST_ITEM_INTEGRITY( pxNewListItem );
dflet 3:a8c249046181 125
dflet 3:a8c249046181 126 /* Insert a new list item into pxList, but rather than sort the list,
dflet 3:a8c249046181 127 makes the new list item the last item to be removed by a call to
dflet 3:a8c249046181 128 listGET_OWNER_OF_NEXT_ENTRY(). */
dflet 3:a8c249046181 129 pxNewListItem->pxNext = pxIndex;
dflet 3:a8c249046181 130 pxNewListItem->pxPrevious = pxIndex->pxPrevious;
dflet 3:a8c249046181 131
dflet 3:a8c249046181 132 /* Only used during decision coverage testing. */
dflet 3:a8c249046181 133 mtCOVERAGE_TEST_DELAY();
dflet 3:a8c249046181 134
dflet 3:a8c249046181 135 pxIndex->pxPrevious->pxNext = pxNewListItem;
dflet 3:a8c249046181 136 pxIndex->pxPrevious = pxNewListItem;
dflet 3:a8c249046181 137
dflet 3:a8c249046181 138 /* Remember which list the item is in. */
dflet 3:a8c249046181 139 pxNewListItem->pvContainer = ( void * ) pxList;
dflet 3:a8c249046181 140
dflet 3:a8c249046181 141 ( pxList->uxNumberOfItems )++;
dflet 3:a8c249046181 142 }
dflet 3:a8c249046181 143 /*-----------------------------------------------------------*/
dflet 3:a8c249046181 144
dflet 3:a8c249046181 145 void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem )
dflet 3:a8c249046181 146 {
dflet 3:a8c249046181 147 ListItem_t *pxIterator;
dflet 3:a8c249046181 148 const TickType_t xValueOfInsertion = pxNewListItem->xItemValue;
dflet 3:a8c249046181 149
dflet 3:a8c249046181 150 /* Only effective when configASSERT() is also defined, these tests may catch
dflet 3:a8c249046181 151 the list data structures being overwritten in memory. They will not catch
dflet 3:a8c249046181 152 data errors caused by incorrect configuration or use of FreeRTOS. */
dflet 3:a8c249046181 153 listTEST_LIST_INTEGRITY( pxList );
dflet 3:a8c249046181 154 listTEST_LIST_ITEM_INTEGRITY( pxNewListItem );
dflet 3:a8c249046181 155
dflet 3:a8c249046181 156 /* Insert the new list item into the list, sorted in xItemValue order.
dflet 3:a8c249046181 157
dflet 3:a8c249046181 158 If the list already contains a list item with the same item value then the
dflet 3:a8c249046181 159 new list item should be placed after it. This ensures that TCB's which are
dflet 3:a8c249046181 160 stored in ready lists (all of which have the same xItemValue value) get a
dflet 3:a8c249046181 161 share of the CPU. However, if the xItemValue is the same as the back marker
dflet 3:a8c249046181 162 the iteration loop below will not end. Therefore the value is checked
dflet 3:a8c249046181 163 first, and the algorithm slightly modified if necessary. */
dflet 3:a8c249046181 164 if( xValueOfInsertion == portMAX_DELAY )
dflet 3:a8c249046181 165 {
dflet 3:a8c249046181 166 pxIterator = pxList->xListEnd.pxPrevious;
dflet 3:a8c249046181 167 }
dflet 3:a8c249046181 168 else
dflet 3:a8c249046181 169 {
dflet 3:a8c249046181 170 /* *** NOTE ***********************************************************
dflet 3:a8c249046181 171 If you find your application is crashing here then likely causes are
dflet 3:a8c249046181 172 listed below. In addition see http://www.freertos.org/FAQHelp.html for
dflet 3:a8c249046181 173 more tips, and ensure configASSERT() is defined!
dflet 3:a8c249046181 174 http://www.freertos.org/a00110.html#configASSERT
dflet 3:a8c249046181 175
dflet 3:a8c249046181 176 1) Stack overflow -
dflet 3:a8c249046181 177 see http://www.freertos.org/Stacks-and-stack-overflow-checking.html
dflet 3:a8c249046181 178 2) Incorrect interrupt priority assignment, especially on Cortex-M
dflet 3:a8c249046181 179 parts where numerically high priority values denote low actual
dflet 3:a8c249046181 180 interrupt priorities, which can seem counter intuitive. See
dflet 3:a8c249046181 181 http://www.freertos.org/RTOS-Cortex-M3-M4.html and the definition
dflet 3:a8c249046181 182 of configMAX_SYSCALL_INTERRUPT_PRIORITY on
dflet 3:a8c249046181 183 http://www.freertos.org/a00110.html
dflet 3:a8c249046181 184 3) Calling an API function from within a critical section or when
dflet 3:a8c249046181 185 the scheduler is suspended, or calling an API function that does
dflet 3:a8c249046181 186 not end in "FromISR" from an interrupt.
dflet 3:a8c249046181 187 4) Using a queue or semaphore before it has been initialised or
dflet 3:a8c249046181 188 before the scheduler has been started (are interrupts firing
dflet 3:a8c249046181 189 before vTaskStartScheduler() has been called?).
dflet 3:a8c249046181 190 **********************************************************************/
dflet 3:a8c249046181 191
dflet 3:a8c249046181 192 for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
dflet 3:a8c249046181 193 {
dflet 3:a8c249046181 194 /* There is nothing to do here, just iterating to the wanted
dflet 3:a8c249046181 195 insertion position. */
dflet 3:a8c249046181 196 }
dflet 3:a8c249046181 197 }
dflet 3:a8c249046181 198
dflet 3:a8c249046181 199 pxNewListItem->pxNext = pxIterator->pxNext;
dflet 3:a8c249046181 200 pxNewListItem->pxNext->pxPrevious = pxNewListItem;
dflet 3:a8c249046181 201 pxNewListItem->pxPrevious = pxIterator;
dflet 3:a8c249046181 202 pxIterator->pxNext = pxNewListItem;
dflet 3:a8c249046181 203
dflet 3:a8c249046181 204 /* Remember which list the item is in. This allows fast removal of the
dflet 3:a8c249046181 205 item later. */
dflet 3:a8c249046181 206 pxNewListItem->pvContainer = ( void * ) pxList;
dflet 3:a8c249046181 207
dflet 3:a8c249046181 208 ( pxList->uxNumberOfItems )++;
dflet 3:a8c249046181 209 }
dflet 3:a8c249046181 210 /*-----------------------------------------------------------*/
dflet 3:a8c249046181 211
dflet 3:a8c249046181 212 UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove )
dflet 3:a8c249046181 213 {
dflet 3:a8c249046181 214 /* The list item knows which list it is in. Obtain the list from the list
dflet 3:a8c249046181 215 item. */
dflet 3:a8c249046181 216 List_t * const pxList = ( List_t * ) pxItemToRemove->pvContainer;
dflet 3:a8c249046181 217
dflet 3:a8c249046181 218 pxItemToRemove->pxNext->pxPrevious = pxItemToRemove->pxPrevious;
dflet 3:a8c249046181 219 pxItemToRemove->pxPrevious->pxNext = pxItemToRemove->pxNext;
dflet 3:a8c249046181 220
dflet 3:a8c249046181 221 /* Only used during decision coverage testing. */
dflet 3:a8c249046181 222 mtCOVERAGE_TEST_DELAY();
dflet 3:a8c249046181 223
dflet 3:a8c249046181 224 /* Make sure the index is left pointing to a valid item. */
dflet 3:a8c249046181 225 if( pxList->pxIndex == pxItemToRemove )
dflet 3:a8c249046181 226 {
dflet 3:a8c249046181 227 pxList->pxIndex = pxItemToRemove->pxPrevious;
dflet 3:a8c249046181 228 }
dflet 3:a8c249046181 229 else
dflet 3:a8c249046181 230 {
dflet 3:a8c249046181 231 mtCOVERAGE_TEST_MARKER();
dflet 3:a8c249046181 232 }
dflet 3:a8c249046181 233
dflet 3:a8c249046181 234 pxItemToRemove->pvContainer = NULL;
dflet 3:a8c249046181 235 ( pxList->uxNumberOfItems )--;
dflet 3:a8c249046181 236
dflet 3:a8c249046181 237 return pxList->uxNumberOfItems;
dflet 3:a8c249046181 238 }
dflet 3:a8c249046181 239 /*-----------------------------------------------------------*/
dflet 3:a8c249046181 240
dflet 3:a8c249046181 241