Mike Pulice / ublox_C200Test

Fork of SprintUSBModemHTTPClientTest by Donatien Garnier

Committer:
sam_grove
Date:
Tue Oct 08 00:08:22 2013 +0000
Revision:
21:3f45e53afe4f
Parent:
5:3f93dd1d4cb3
Added http client test. Return from post seems to be a bit wonky but haven't looked closely at this

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 5:3f93dd1d4cb3 1 /*----------------------------------------------------------------------------
sam_grove 5:3f93dd1d4cb3 2 * RL-ARM - RTX
sam_grove 5:3f93dd1d4cb3 3 *----------------------------------------------------------------------------
sam_grove 5:3f93dd1d4cb3 4 * Name: RT_EVENT.C
sam_grove 5:3f93dd1d4cb3 5 * Purpose: Implements waits and wake-ups for event flags
sam_grove 5:3f93dd1d4cb3 6 * Rev.: V4.60
sam_grove 5:3f93dd1d4cb3 7 *----------------------------------------------------------------------------
sam_grove 5:3f93dd1d4cb3 8 *
sam_grove 5:3f93dd1d4cb3 9 * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
sam_grove 5:3f93dd1d4cb3 10 * All rights reserved.
sam_grove 5:3f93dd1d4cb3 11 * Redistribution and use in source and binary forms, with or without
sam_grove 5:3f93dd1d4cb3 12 * modification, are permitted provided that the following conditions are met:
sam_grove 5:3f93dd1d4cb3 13 * - Redistributions of source code must retain the above copyright
sam_grove 5:3f93dd1d4cb3 14 * notice, this list of conditions and the following disclaimer.
sam_grove 5:3f93dd1d4cb3 15 * - Redistributions in binary form must reproduce the above copyright
sam_grove 5:3f93dd1d4cb3 16 * notice, this list of conditions and the following disclaimer in the
sam_grove 5:3f93dd1d4cb3 17 * documentation and/or other materials provided with the distribution.
sam_grove 5:3f93dd1d4cb3 18 * - Neither the name of ARM nor the names of its contributors may be used
sam_grove 5:3f93dd1d4cb3 19 * to endorse or promote products derived from this software without
sam_grove 5:3f93dd1d4cb3 20 * specific prior written permission.
sam_grove 5:3f93dd1d4cb3 21 *
sam_grove 5:3f93dd1d4cb3 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
sam_grove 5:3f93dd1d4cb3 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sam_grove 5:3f93dd1d4cb3 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sam_grove 5:3f93dd1d4cb3 25 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
sam_grove 5:3f93dd1d4cb3 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
sam_grove 5:3f93dd1d4cb3 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
sam_grove 5:3f93dd1d4cb3 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
sam_grove 5:3f93dd1d4cb3 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
sam_grove 5:3f93dd1d4cb3 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
sam_grove 5:3f93dd1d4cb3 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
sam_grove 5:3f93dd1d4cb3 32 * POSSIBILITY OF SUCH DAMAGE.
sam_grove 5:3f93dd1d4cb3 33 *---------------------------------------------------------------------------*/
sam_grove 5:3f93dd1d4cb3 34
sam_grove 5:3f93dd1d4cb3 35 #include "rt_TypeDef.h"
sam_grove 5:3f93dd1d4cb3 36 #include "RTX_Conf.h"
sam_grove 5:3f93dd1d4cb3 37 #include "rt_System.h"
sam_grove 5:3f93dd1d4cb3 38 #include "rt_Event.h"
sam_grove 5:3f93dd1d4cb3 39 #include "rt_List.h"
sam_grove 5:3f93dd1d4cb3 40 #include "rt_Task.h"
sam_grove 5:3f93dd1d4cb3 41 #include "rt_HAL_CM.h"
sam_grove 5:3f93dd1d4cb3 42
sam_grove 5:3f93dd1d4cb3 43
sam_grove 5:3f93dd1d4cb3 44 /*----------------------------------------------------------------------------
sam_grove 5:3f93dd1d4cb3 45 * Functions
sam_grove 5:3f93dd1d4cb3 46 *---------------------------------------------------------------------------*/
sam_grove 5:3f93dd1d4cb3 47
sam_grove 5:3f93dd1d4cb3 48
sam_grove 5:3f93dd1d4cb3 49 /*--------------------------- rt_evt_wait -----------------------------------*/
sam_grove 5:3f93dd1d4cb3 50
sam_grove 5:3f93dd1d4cb3 51 OS_RESULT rt_evt_wait (U16 wait_flags, U16 timeout, BOOL and_wait) {
sam_grove 5:3f93dd1d4cb3 52 /* Wait for one or more event flags with optional time-out. */
sam_grove 5:3f93dd1d4cb3 53 /* "wait_flags" identifies the flags to wait for. */
sam_grove 5:3f93dd1d4cb3 54 /* "timeout" is the time-out limit in system ticks (0xffff if no time-out) */
sam_grove 5:3f93dd1d4cb3 55 /* "and_wait" specifies the AND-ing of "wait_flags" as condition to be met */
sam_grove 5:3f93dd1d4cb3 56 /* to complete the wait. (OR-ing if set to 0). */
sam_grove 5:3f93dd1d4cb3 57 U32 block_state;
sam_grove 5:3f93dd1d4cb3 58
sam_grove 5:3f93dd1d4cb3 59 if (and_wait) {
sam_grove 5:3f93dd1d4cb3 60 /* Check for AND-connected events */
sam_grove 5:3f93dd1d4cb3 61 if ((os_tsk.run->events & wait_flags) == wait_flags) {
sam_grove 5:3f93dd1d4cb3 62 os_tsk.run->events &= ~wait_flags;
sam_grove 5:3f93dd1d4cb3 63 return (OS_R_EVT);
sam_grove 5:3f93dd1d4cb3 64 }
sam_grove 5:3f93dd1d4cb3 65 block_state = WAIT_AND;
sam_grove 5:3f93dd1d4cb3 66 }
sam_grove 5:3f93dd1d4cb3 67 else {
sam_grove 5:3f93dd1d4cb3 68 /* Check for OR-connected events */
sam_grove 5:3f93dd1d4cb3 69 if (os_tsk.run->events & wait_flags) {
sam_grove 5:3f93dd1d4cb3 70 os_tsk.run->waits = os_tsk.run->events & wait_flags;
sam_grove 5:3f93dd1d4cb3 71 os_tsk.run->events &= ~wait_flags;
sam_grove 5:3f93dd1d4cb3 72 return (OS_R_EVT);
sam_grove 5:3f93dd1d4cb3 73 }
sam_grove 5:3f93dd1d4cb3 74 block_state = WAIT_OR;
sam_grove 5:3f93dd1d4cb3 75 }
sam_grove 5:3f93dd1d4cb3 76 /* Task has to wait */
sam_grove 5:3f93dd1d4cb3 77 os_tsk.run->waits = wait_flags;
sam_grove 5:3f93dd1d4cb3 78 rt_block (timeout, (U8)block_state);
sam_grove 5:3f93dd1d4cb3 79 return (OS_R_TMO);
sam_grove 5:3f93dd1d4cb3 80 }
sam_grove 5:3f93dd1d4cb3 81
sam_grove 5:3f93dd1d4cb3 82
sam_grove 5:3f93dd1d4cb3 83 /*--------------------------- rt_evt_set ------------------------------------*/
sam_grove 5:3f93dd1d4cb3 84
sam_grove 5:3f93dd1d4cb3 85 void rt_evt_set (U16 event_flags, OS_TID task_id) {
sam_grove 5:3f93dd1d4cb3 86 /* Set one or more event flags of a selectable task. */
sam_grove 5:3f93dd1d4cb3 87 P_TCB p_tcb;
sam_grove 5:3f93dd1d4cb3 88
sam_grove 5:3f93dd1d4cb3 89 p_tcb = os_active_TCB[task_id-1];
sam_grove 5:3f93dd1d4cb3 90 if (p_tcb == NULL) {
sam_grove 5:3f93dd1d4cb3 91 return;
sam_grove 5:3f93dd1d4cb3 92 }
sam_grove 5:3f93dd1d4cb3 93 p_tcb->events |= event_flags;
sam_grove 5:3f93dd1d4cb3 94 event_flags = p_tcb->waits;
sam_grove 5:3f93dd1d4cb3 95 /* If the task is not waiting for an event, it should not be put */
sam_grove 5:3f93dd1d4cb3 96 /* to ready state. */
sam_grove 5:3f93dd1d4cb3 97 if (p_tcb->state == WAIT_AND) {
sam_grove 5:3f93dd1d4cb3 98 /* Check for AND-connected events */
sam_grove 5:3f93dd1d4cb3 99 if ((p_tcb->events & event_flags) == event_flags) {
sam_grove 5:3f93dd1d4cb3 100 goto wkup;
sam_grove 5:3f93dd1d4cb3 101 }
sam_grove 5:3f93dd1d4cb3 102 }
sam_grove 5:3f93dd1d4cb3 103 if (p_tcb->state == WAIT_OR) {
sam_grove 5:3f93dd1d4cb3 104 /* Check for OR-connected events */
sam_grove 5:3f93dd1d4cb3 105 if (p_tcb->events & event_flags) {
sam_grove 5:3f93dd1d4cb3 106 p_tcb->waits &= p_tcb->events;
sam_grove 5:3f93dd1d4cb3 107 wkup: p_tcb->events &= ~event_flags;
sam_grove 5:3f93dd1d4cb3 108 rt_rmv_dly (p_tcb);
sam_grove 5:3f93dd1d4cb3 109 p_tcb->state = READY;
sam_grove 5:3f93dd1d4cb3 110 #ifdef __CMSIS_RTOS
sam_grove 5:3f93dd1d4cb3 111 rt_ret_val2(p_tcb, 0x08/*osEventSignal*/, p_tcb->waits);
sam_grove 5:3f93dd1d4cb3 112 #else
sam_grove 5:3f93dd1d4cb3 113 rt_ret_val (p_tcb, OS_R_EVT);
sam_grove 5:3f93dd1d4cb3 114 #endif
sam_grove 5:3f93dd1d4cb3 115 rt_dispatch (p_tcb);
sam_grove 5:3f93dd1d4cb3 116 }
sam_grove 5:3f93dd1d4cb3 117 }
sam_grove 5:3f93dd1d4cb3 118 }
sam_grove 5:3f93dd1d4cb3 119
sam_grove 5:3f93dd1d4cb3 120
sam_grove 5:3f93dd1d4cb3 121 /*--------------------------- rt_evt_clr ------------------------------------*/
sam_grove 5:3f93dd1d4cb3 122
sam_grove 5:3f93dd1d4cb3 123 void rt_evt_clr (U16 clear_flags, OS_TID task_id) {
sam_grove 5:3f93dd1d4cb3 124 /* Clear one or more event flags (identified by "clear_flags") of a */
sam_grove 5:3f93dd1d4cb3 125 /* selectable task (identified by "task"). */
sam_grove 5:3f93dd1d4cb3 126 P_TCB task = os_active_TCB[task_id-1];
sam_grove 5:3f93dd1d4cb3 127
sam_grove 5:3f93dd1d4cb3 128 if (task == NULL) {
sam_grove 5:3f93dd1d4cb3 129 return;
sam_grove 5:3f93dd1d4cb3 130 }
sam_grove 5:3f93dd1d4cb3 131 task->events &= ~clear_flags;
sam_grove 5:3f93dd1d4cb3 132 }
sam_grove 5:3f93dd1d4cb3 133
sam_grove 5:3f93dd1d4cb3 134
sam_grove 5:3f93dd1d4cb3 135 /*--------------------------- isr_evt_set -----------------------------------*/
sam_grove 5:3f93dd1d4cb3 136
sam_grove 5:3f93dd1d4cb3 137 void isr_evt_set (U16 event_flags, OS_TID task_id) {
sam_grove 5:3f93dd1d4cb3 138 /* Same function as "os_evt_set", but to be called by ISRs. */
sam_grove 5:3f93dd1d4cb3 139 P_TCB p_tcb = os_active_TCB[task_id-1];
sam_grove 5:3f93dd1d4cb3 140
sam_grove 5:3f93dd1d4cb3 141 if (p_tcb == NULL) {
sam_grove 5:3f93dd1d4cb3 142 return;
sam_grove 5:3f93dd1d4cb3 143 }
sam_grove 5:3f93dd1d4cb3 144 rt_psq_enq (p_tcb, event_flags);
sam_grove 5:3f93dd1d4cb3 145 rt_psh_req ();
sam_grove 5:3f93dd1d4cb3 146 }
sam_grove 5:3f93dd1d4cb3 147
sam_grove 5:3f93dd1d4cb3 148
sam_grove 5:3f93dd1d4cb3 149 /*--------------------------- rt_evt_get ------------------------------------*/
sam_grove 5:3f93dd1d4cb3 150
sam_grove 5:3f93dd1d4cb3 151 U16 rt_evt_get (void) {
sam_grove 5:3f93dd1d4cb3 152 /* Get events of a running task after waiting for OR connected events. */
sam_grove 5:3f93dd1d4cb3 153 return (os_tsk.run->waits);
sam_grove 5:3f93dd1d4cb3 154 }
sam_grove 5:3f93dd1d4cb3 155
sam_grove 5:3f93dd1d4cb3 156
sam_grove 5:3f93dd1d4cb3 157 /*--------------------------- rt_evt_psh ------------------------------------*/
sam_grove 5:3f93dd1d4cb3 158
sam_grove 5:3f93dd1d4cb3 159 void rt_evt_psh (P_TCB p_CB, U16 set_flags) {
sam_grove 5:3f93dd1d4cb3 160 /* Check if task has to be waken up */
sam_grove 5:3f93dd1d4cb3 161 U16 event_flags;
sam_grove 5:3f93dd1d4cb3 162
sam_grove 5:3f93dd1d4cb3 163 p_CB->events |= set_flags;
sam_grove 5:3f93dd1d4cb3 164 event_flags = p_CB->waits;
sam_grove 5:3f93dd1d4cb3 165 if (p_CB->state == WAIT_AND) {
sam_grove 5:3f93dd1d4cb3 166 /* Check for AND-connected events */
sam_grove 5:3f93dd1d4cb3 167 if ((p_CB->events & event_flags) == event_flags) {
sam_grove 5:3f93dd1d4cb3 168 goto rdy;
sam_grove 5:3f93dd1d4cb3 169 }
sam_grove 5:3f93dd1d4cb3 170 }
sam_grove 5:3f93dd1d4cb3 171 if (p_CB->state == WAIT_OR) {
sam_grove 5:3f93dd1d4cb3 172 /* Check for OR-connected events */
sam_grove 5:3f93dd1d4cb3 173 if (p_CB->events & event_flags) {
sam_grove 5:3f93dd1d4cb3 174 p_CB->waits &= p_CB->events;
sam_grove 5:3f93dd1d4cb3 175 rdy: p_CB->events &= ~event_flags;
sam_grove 5:3f93dd1d4cb3 176 rt_rmv_dly (p_CB);
sam_grove 5:3f93dd1d4cb3 177 p_CB->state = READY;
sam_grove 5:3f93dd1d4cb3 178 #ifdef __CMSIS_RTOS
sam_grove 5:3f93dd1d4cb3 179 rt_ret_val2(p_CB, 0x08/*osEventSignal*/, p_CB->waits);
sam_grove 5:3f93dd1d4cb3 180 #else
sam_grove 5:3f93dd1d4cb3 181 rt_ret_val (p_CB, OS_R_EVT);
sam_grove 5:3f93dd1d4cb3 182 #endif
sam_grove 5:3f93dd1d4cb3 183 rt_put_prio (&os_rdy, p_CB);
sam_grove 5:3f93dd1d4cb3 184 }
sam_grove 5:3f93dd1d4cb3 185 }
sam_grove 5:3f93dd1d4cb3 186 }
sam_grove 5:3f93dd1d4cb3 187
sam_grove 5:3f93dd1d4cb3 188 /*----------------------------------------------------------------------------
sam_grove 5:3f93dd1d4cb3 189 * end of file
sam_grove 5:3f93dd1d4cb3 190 *---------------------------------------------------------------------------*/