A board support package for the LPC4088 Display Module.

Dependencies:   DM_HttpServer DM_USBHost

Dependents:   lpc4088_displaymodule_emwin lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI ... more

Fork of DMSupport by EmbeddedArtists AB

Committer:
embeddedartists
Date:
Thu Dec 11 18:23:07 2014 +0000
Revision:
9:a33326afd686
Parent:
2:887c6b45e7fa
Child:
34:fc366bab393f
Updated documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 2:887c6b45e7fa 1 /*
embeddedartists 2:887c6b45e7fa 2 * Copyright 2014 Embedded Artists AB
embeddedartists 2:887c6b45e7fa 3 *
embeddedartists 2:887c6b45e7fa 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 2:887c6b45e7fa 5 * you may not use this file except in compliance with the License.
embeddedartists 2:887c6b45e7fa 6 * You may obtain a copy of the License at
embeddedartists 2:887c6b45e7fa 7 *
embeddedartists 2:887c6b45e7fa 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 2:887c6b45e7fa 9 *
embeddedartists 2:887c6b45e7fa 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 2:887c6b45e7fa 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 2:887c6b45e7fa 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 2:887c6b45e7fa 13 * See the License for the specific language governing permissions and
embeddedartists 2:887c6b45e7fa 14 * limitations under the License.
embeddedartists 2:887c6b45e7fa 15 */
embeddedartists 2:887c6b45e7fa 16
embeddedartists 2:887c6b45e7fa 17 #ifndef RTOSLOG_H
embeddedartists 2:887c6b45e7fa 18 #define RTOSLOG_H
embeddedartists 2:887c6b45e7fa 19
embeddedartists 2:887c6b45e7fa 20 #include "mbed.h"
embeddedartists 2:887c6b45e7fa 21 #include "rtos.h"
embeddedartists 2:887c6b45e7fa 22 #include "dm_board_config.h"
embeddedartists 2:887c6b45e7fa 23
embeddedartists 2:887c6b45e7fa 24 /**
embeddedartists 2:887c6b45e7fa 25 * All threads can independantly call the printf function in the RtosLog class
embeddedartists 9:a33326afd686 26 * without risk of getting the output tangled up.
embeddedartists 2:887c6b45e7fa 27 *
embeddedartists 2:887c6b45e7fa 28 * The RtosLog class uses a Thread to process the messages one at a time.
embeddedartists 9:a33326afd686 29 *
embeddedartists 9:a33326afd686 30 *
embeddedartists 9:a33326afd686 31 * Example of using the RtosLog class:
embeddedartists 9:a33326afd686 32 *
embeddedartists 9:a33326afd686 33 * @code
embeddedartists 9:a33326afd686 34 * #include "mbed.h"
embeddedartists 9:a33326afd686 35 * #include "DMBoard.h"
embeddedartists 9:a33326afd686 36 *
embeddedartists 9:a33326afd686 37 * void myTask(void const*args) {
embeddedartists 9:a33326afd686 38 * RtosLog* log = DMBoard::instance().logger();
embeddedartists 9:a33326afd686 39 * ...
embeddedartists 9:a33326afd686 40 * log->printf("Hello world!\n");
embeddedartists 9:a33326afd686 41 * ...
embeddedartists 9:a33326afd686 42 * }
embeddedartists 9:a33326afd686 43 * @endcode
embeddedartists 9:a33326afd686 44 *
embeddedartists 2:887c6b45e7fa 45 */
embeddedartists 2:887c6b45e7fa 46 class RtosLog {
embeddedartists 2:887c6b45e7fa 47 public:
embeddedartists 2:887c6b45e7fa 48 enum Constants {
embeddedartists 2:887c6b45e7fa 49 MessageLen = 80,
embeddedartists 2:887c6b45e7fa 50 NumMessages = 16,
embeddedartists 2:887c6b45e7fa 51 };
embeddedartists 2:887c6b45e7fa 52
embeddedartists 2:887c6b45e7fa 53 RtosLog();
embeddedartists 2:887c6b45e7fa 54 ~RtosLog();
embeddedartists 2:887c6b45e7fa 55
embeddedartists 2:887c6b45e7fa 56 /** Starts the logger thread
embeddedartists 2:887c6b45e7fa 57 */
embeddedartists 2:887c6b45e7fa 58 void init();
embeddedartists 2:887c6b45e7fa 59
embeddedartists 2:887c6b45e7fa 60 int printf(const char* format, ...);
embeddedartists 2:887c6b45e7fa 61
embeddedartists 2:887c6b45e7fa 62 private:
embeddedartists 2:887c6b45e7fa 63
embeddedartists 2:887c6b45e7fa 64 typedef struct {
embeddedartists 2:887c6b45e7fa 65 char* ptr; /* Non-NULL if memory is allocated */
embeddedartists 2:887c6b45e7fa 66 char msg[MessageLen+1]; /* A counter value */
embeddedartists 2:887c6b45e7fa 67 } message_t;
embeddedartists 2:887c6b45e7fa 68
embeddedartists 2:887c6b45e7fa 69 MemoryPool<message_t, NumMessages> _mpool;
embeddedartists 2:887c6b45e7fa 70 Queue<message_t, NumMessages> _queue;
embeddedartists 2:887c6b45e7fa 71 Semaphore _sem;
embeddedartists 2:887c6b45e7fa 72 Serial _serial;
embeddedartists 2:887c6b45e7fa 73 Thread* _thr;
embeddedartists 2:887c6b45e7fa 74
embeddedartists 2:887c6b45e7fa 75 static void logTask(void const* args);
embeddedartists 2:887c6b45e7fa 76 };
embeddedartists 2:887c6b45e7fa 77
embeddedartists 2:887c6b45e7fa 78 #endif