TI's CC3100 websocket camera demo with Arducam mini ov5642 and freertos. Should work with other M3's. Work in progress test demo.

Dependencies:   mbed

Committer:
dflet
Date:
Fri Sep 11 15:38:33 2015 +0000
Revision:
1:e448e81c416f
Parent:
0:400d8e75a8d0
Removed some debud.

Who changed what in which revision?

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