Integrating the ublox LISA C200 modem

Fork of SprintUSBModemHTTPClientTest by Donatien Garnier

Committer:
sam_grove
Date:
Thu Sep 26 00:44:20 2013 -0500
Revision:
5:3f93dd1d4cb3
Exported program and replaced contents of the repo with the source
to build and debug using keil mdk. Libs NOT upto date are lwip, lwip-sys
and socket. these have newer versions under mbed_official but were starting
from a know working point

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 5:3f93dd1d4cb3 1 /* mbed Microcontroller Library
sam_grove 5:3f93dd1d4cb3 2 * Copyright (c) 2006-2012 ARM Limited
sam_grove 5:3f93dd1d4cb3 3 *
sam_grove 5:3f93dd1d4cb3 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
sam_grove 5:3f93dd1d4cb3 5 * of this software and associated documentation files (the "Software"), to deal
sam_grove 5:3f93dd1d4cb3 6 * in the Software without restriction, including without limitation the rights
sam_grove 5:3f93dd1d4cb3 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
sam_grove 5:3f93dd1d4cb3 8 * copies of the Software, and to permit persons to whom the Software is
sam_grove 5:3f93dd1d4cb3 9 * furnished to do so, subject to the following conditions:
sam_grove 5:3f93dd1d4cb3 10 *
sam_grove 5:3f93dd1d4cb3 11 * The above copyright notice and this permission notice shall be included in
sam_grove 5:3f93dd1d4cb3 12 * all copies or substantial portions of the Software.
sam_grove 5:3f93dd1d4cb3 13 *
sam_grove 5:3f93dd1d4cb3 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
sam_grove 5:3f93dd1d4cb3 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
sam_grove 5:3f93dd1d4cb3 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
sam_grove 5:3f93dd1d4cb3 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
sam_grove 5:3f93dd1d4cb3 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
sam_grove 5:3f93dd1d4cb3 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
sam_grove 5:3f93dd1d4cb3 20 * SOFTWARE.
sam_grove 5:3f93dd1d4cb3 21 */
sam_grove 5:3f93dd1d4cb3 22 #ifndef MAIL_H
sam_grove 5:3f93dd1d4cb3 23 #define MAIL_H
sam_grove 5:3f93dd1d4cb3 24
sam_grove 5:3f93dd1d4cb3 25 #include <stdint.h>
sam_grove 5:3f93dd1d4cb3 26 #include <string.h>
sam_grove 5:3f93dd1d4cb3 27
sam_grove 5:3f93dd1d4cb3 28 #include "cmsis_os.h"
sam_grove 5:3f93dd1d4cb3 29
sam_grove 5:3f93dd1d4cb3 30 namespace rtos {
sam_grove 5:3f93dd1d4cb3 31
sam_grove 5:3f93dd1d4cb3 32 /** The Mail class allow to control, send, receive, or wait for mail.
sam_grove 5:3f93dd1d4cb3 33 A mail is a memory block that is send to a thread or interrupt service routine.
sam_grove 5:3f93dd1d4cb3 34 @tparam T data type of a single message element.
sam_grove 5:3f93dd1d4cb3 35 @tparam queue_sz maximum number of messages in queue.
sam_grove 5:3f93dd1d4cb3 36 */
sam_grove 5:3f93dd1d4cb3 37 template<typename T, uint32_t queue_sz>
sam_grove 5:3f93dd1d4cb3 38 class Mail {
sam_grove 5:3f93dd1d4cb3 39 public:
sam_grove 5:3f93dd1d4cb3 40 /** Create and Initialise Mail queue. */
sam_grove 5:3f93dd1d4cb3 41 Mail() {
sam_grove 5:3f93dd1d4cb3 42 #ifdef CMSIS_OS_RTX
sam_grove 5:3f93dd1d4cb3 43 memset(_mail_q, 0, sizeof(_mail_q));
sam_grove 5:3f93dd1d4cb3 44 _mail_p[0] = _mail_q;
sam_grove 5:3f93dd1d4cb3 45
sam_grove 5:3f93dd1d4cb3 46 memset(_mail_m, 0, sizeof(_mail_m));
sam_grove 5:3f93dd1d4cb3 47 _mail_p[1] = _mail_m;
sam_grove 5:3f93dd1d4cb3 48
sam_grove 5:3f93dd1d4cb3 49 _mail_def.pool = _mail_p;
sam_grove 5:3f93dd1d4cb3 50 _mail_def.queue_sz = queue_sz;
sam_grove 5:3f93dd1d4cb3 51 _mail_def.item_sz = sizeof(T);
sam_grove 5:3f93dd1d4cb3 52 #endif
sam_grove 5:3f93dd1d4cb3 53 _mail_id = osMailCreate(&_mail_def, NULL);
sam_grove 5:3f93dd1d4cb3 54 }
sam_grove 5:3f93dd1d4cb3 55
sam_grove 5:3f93dd1d4cb3 56 /** Allocate a memory block of type T
sam_grove 5:3f93dd1d4cb3 57 @param millisec timeout value or 0 in case of no time-out. (default: 0).
sam_grove 5:3f93dd1d4cb3 58 @return pointer to memory block that can be filled with mail or NULL in case error.
sam_grove 5:3f93dd1d4cb3 59 */
sam_grove 5:3f93dd1d4cb3 60 T* alloc(uint32_t millisec=0) {
sam_grove 5:3f93dd1d4cb3 61 return (T*)osMailAlloc(_mail_id, millisec);
sam_grove 5:3f93dd1d4cb3 62 }
sam_grove 5:3f93dd1d4cb3 63
sam_grove 5:3f93dd1d4cb3 64 /** Allocate a memory block of type T and set memory block to zero.
sam_grove 5:3f93dd1d4cb3 65 @param millisec timeout value or 0 in case of no time-out. (default: 0).
sam_grove 5:3f93dd1d4cb3 66 @return pointer to memory block that can be filled with mail or NULL in case error.
sam_grove 5:3f93dd1d4cb3 67 */
sam_grove 5:3f93dd1d4cb3 68 T* calloc(uint32_t millisec=0) {
sam_grove 5:3f93dd1d4cb3 69 return (T*)osMailCAlloc(_mail_id, millisec);
sam_grove 5:3f93dd1d4cb3 70 }
sam_grove 5:3f93dd1d4cb3 71
sam_grove 5:3f93dd1d4cb3 72 /** Put a mail in the queue.
sam_grove 5:3f93dd1d4cb3 73 @param mptr memory block previously allocated with Mail::alloc or Mail::calloc.
sam_grove 5:3f93dd1d4cb3 74 @return status code that indicates the execution status of the function.
sam_grove 5:3f93dd1d4cb3 75 */
sam_grove 5:3f93dd1d4cb3 76 osStatus put(T *mptr) {
sam_grove 5:3f93dd1d4cb3 77 return osMailPut(_mail_id, (void*)mptr);
sam_grove 5:3f93dd1d4cb3 78 }
sam_grove 5:3f93dd1d4cb3 79
sam_grove 5:3f93dd1d4cb3 80 /** Get a mail from a queue.
sam_grove 5:3f93dd1d4cb3 81 @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
sam_grove 5:3f93dd1d4cb3 82 @return event that contains mail information or error code.
sam_grove 5:3f93dd1d4cb3 83 */
sam_grove 5:3f93dd1d4cb3 84 osEvent get(uint32_t millisec=osWaitForever) {
sam_grove 5:3f93dd1d4cb3 85 return osMailGet(_mail_id, millisec);
sam_grove 5:3f93dd1d4cb3 86 }
sam_grove 5:3f93dd1d4cb3 87
sam_grove 5:3f93dd1d4cb3 88 /** Free a memory block from a mail.
sam_grove 5:3f93dd1d4cb3 89 @param mptr pointer to the memory block that was obtained with Mail::get.
sam_grove 5:3f93dd1d4cb3 90 @return status code that indicates the execution status of the function.
sam_grove 5:3f93dd1d4cb3 91 */
sam_grove 5:3f93dd1d4cb3 92 osStatus free(T *mptr) {
sam_grove 5:3f93dd1d4cb3 93 return osMailFree(_mail_id, (void*)mptr);
sam_grove 5:3f93dd1d4cb3 94 }
sam_grove 5:3f93dd1d4cb3 95
sam_grove 5:3f93dd1d4cb3 96 private:
sam_grove 5:3f93dd1d4cb3 97 osMailQId _mail_id;
sam_grove 5:3f93dd1d4cb3 98 osMailQDef_t _mail_def;
sam_grove 5:3f93dd1d4cb3 99 #ifdef CMSIS_OS_RTX
sam_grove 5:3f93dd1d4cb3 100 uint32_t _mail_q[4+(queue_sz)];
sam_grove 5:3f93dd1d4cb3 101 uint32_t _mail_m[3+((sizeof(T)+3)/4)*(queue_sz)];
sam_grove 5:3f93dd1d4cb3 102 void *_mail_p[2];
sam_grove 5:3f93dd1d4cb3 103 #endif
sam_grove 5:3f93dd1d4cb3 104 };
sam_grove 5:3f93dd1d4cb3 105
sam_grove 5:3f93dd1d4cb3 106 }
sam_grove 5:3f93dd1d4cb3 107
sam_grove 5:3f93dd1d4cb3 108 #endif
sam_grove 5:3f93dd1d4cb3 109