STM Imu acquisition setup using ethernet

Dependencies:   F7_Ethernet mbed HTS221 LPS22HB LSM303AGR LSM6DSL

Fork of Nucleo_F746ZG_Ethernet by Dieter Graef

Committer:
nirnakern
Date:
Mon Oct 15 14:41:19 2018 +0000
Revision:
9:45a96c88754d
Parent:
0:f9b6112278fe
First Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DieterGraef 0:f9b6112278fe 1 /* mbed Microcontroller Library
DieterGraef 0:f9b6112278fe 2 * Copyright (c) 2006-2012 ARM Limited
DieterGraef 0:f9b6112278fe 3 *
DieterGraef 0:f9b6112278fe 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
DieterGraef 0:f9b6112278fe 5 * of this software and associated documentation files (the "Software"), to deal
DieterGraef 0:f9b6112278fe 6 * in the Software without restriction, including without limitation the rights
DieterGraef 0:f9b6112278fe 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
DieterGraef 0:f9b6112278fe 8 * copies of the Software, and to permit persons to whom the Software is
DieterGraef 0:f9b6112278fe 9 * furnished to do so, subject to the following conditions:
DieterGraef 0:f9b6112278fe 10 *
DieterGraef 0:f9b6112278fe 11 * The above copyright notice and this permission notice shall be included in
DieterGraef 0:f9b6112278fe 12 * all copies or substantial portions of the Software.
DieterGraef 0:f9b6112278fe 13 *
DieterGraef 0:f9b6112278fe 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
DieterGraef 0:f9b6112278fe 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
DieterGraef 0:f9b6112278fe 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
DieterGraef 0:f9b6112278fe 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
DieterGraef 0:f9b6112278fe 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
DieterGraef 0:f9b6112278fe 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
DieterGraef 0:f9b6112278fe 20 * SOFTWARE.
DieterGraef 0:f9b6112278fe 21 */
DieterGraef 0:f9b6112278fe 22 #ifndef THREAD_H
DieterGraef 0:f9b6112278fe 23 #define THREAD_H
DieterGraef 0:f9b6112278fe 24
DieterGraef 0:f9b6112278fe 25 #include <stdint.h>
DieterGraef 0:f9b6112278fe 26 #include "cmsis_os.h"
DieterGraef 0:f9b6112278fe 27
DieterGraef 0:f9b6112278fe 28 namespace rtos {
DieterGraef 0:f9b6112278fe 29
DieterGraef 0:f9b6112278fe 30 /** The Thread class allow defining, creating, and controlling thread functions in the system. */
DieterGraef 0:f9b6112278fe 31 class Thread {
DieterGraef 0:f9b6112278fe 32 public:
DieterGraef 0:f9b6112278fe 33 /** Create a new thread, and start it executing the specified function.
DieterGraef 0:f9b6112278fe 34 @param task function to be executed by this thread.
DieterGraef 0:f9b6112278fe 35 @param argument pointer that is passed to the thread function as start argument. (default: NULL).
DieterGraef 0:f9b6112278fe 36 @param priority initial priority of the thread function. (default: osPriorityNormal).
DieterGraef 0:f9b6112278fe 37 @param stack_size stack size (in bytes) requirements for the thread function. (default: DEFAULT_STACK_SIZE).
DieterGraef 0:f9b6112278fe 38 @param stack_pointer pointer to the stack area to be used by this thread (default: NULL).
DieterGraef 0:f9b6112278fe 39 */
DieterGraef 0:f9b6112278fe 40 Thread(void (*task)(void const *argument), void *argument=NULL,
DieterGraef 0:f9b6112278fe 41 osPriority priority=osPriorityNormal,
DieterGraef 0:f9b6112278fe 42 uint32_t stack_size=DEFAULT_STACK_SIZE,
DieterGraef 0:f9b6112278fe 43 unsigned char *stack_pointer=NULL);
DieterGraef 0:f9b6112278fe 44
DieterGraef 0:f9b6112278fe 45 /** Terminate execution of a thread and remove it from Active Threads
DieterGraef 0:f9b6112278fe 46 @return status code that indicates the execution status of the function.
DieterGraef 0:f9b6112278fe 47 */
DieterGraef 0:f9b6112278fe 48 osStatus terminate();
DieterGraef 0:f9b6112278fe 49
DieterGraef 0:f9b6112278fe 50 /** Set priority of an active thread
DieterGraef 0:f9b6112278fe 51 @param priority new priority value for the thread function.
DieterGraef 0:f9b6112278fe 52 @return status code that indicates the execution status of the function.
DieterGraef 0:f9b6112278fe 53 */
DieterGraef 0:f9b6112278fe 54 osStatus set_priority(osPriority priority);
DieterGraef 0:f9b6112278fe 55
DieterGraef 0:f9b6112278fe 56 /** Get priority of an active thread
DieterGraef 0:f9b6112278fe 57 @return current priority value of the thread function.
DieterGraef 0:f9b6112278fe 58 */
DieterGraef 0:f9b6112278fe 59 osPriority get_priority();
DieterGraef 0:f9b6112278fe 60
DieterGraef 0:f9b6112278fe 61 /** Set the specified Signal Flags of an active thread.
DieterGraef 0:f9b6112278fe 62 @param signals specifies the signal flags of the thread that should be set.
DieterGraef 0:f9b6112278fe 63 @return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
DieterGraef 0:f9b6112278fe 64 */
DieterGraef 0:f9b6112278fe 65 int32_t signal_set(int32_t signals);
DieterGraef 0:f9b6112278fe 66
DieterGraef 0:f9b6112278fe 67 /** Clears the specified Signal Flags of an active thread.
DieterGraef 0:f9b6112278fe 68 @param signals specifies the signal flags of the thread that should be cleared.
DieterGraef 0:f9b6112278fe 69 @return resultant signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
DieterGraef 0:f9b6112278fe 70 */
DieterGraef 0:f9b6112278fe 71 int32_t signal_clr(int32_t signals);
DieterGraef 0:f9b6112278fe 72
DieterGraef 0:f9b6112278fe 73 /** State of the Thread */
DieterGraef 0:f9b6112278fe 74 enum State {
DieterGraef 0:f9b6112278fe 75 Inactive, /**< Not created or terminated */
DieterGraef 0:f9b6112278fe 76 Ready, /**< Ready to run */
DieterGraef 0:f9b6112278fe 77 Running, /**< Running */
DieterGraef 0:f9b6112278fe 78 WaitingDelay, /**< Waiting for a delay to occur */
DieterGraef 0:f9b6112278fe 79 WaitingInterval, /**< Waiting for an interval to occur */
DieterGraef 0:f9b6112278fe 80 WaitingOr, /**< Waiting for one event in a set to occur */
DieterGraef 0:f9b6112278fe 81 WaitingAnd, /**< Waiting for multiple events in a set to occur */
DieterGraef 0:f9b6112278fe 82 WaitingSemaphore, /**< Waiting for a semaphore event to occur */
DieterGraef 0:f9b6112278fe 83 WaitingMailbox, /**< Waiting for a mailbox event to occur */
DieterGraef 0:f9b6112278fe 84 WaitingMutex, /**< Waiting for a mutex event to occur */
DieterGraef 0:f9b6112278fe 85 };
DieterGraef 0:f9b6112278fe 86
DieterGraef 0:f9b6112278fe 87 /** State of this Thread
DieterGraef 0:f9b6112278fe 88 @return the State of this Thread
DieterGraef 0:f9b6112278fe 89 */
DieterGraef 0:f9b6112278fe 90 State get_state();
DieterGraef 0:f9b6112278fe 91
DieterGraef 0:f9b6112278fe 92 /** Get the total stack memory size for this Thread
DieterGraef 0:f9b6112278fe 93 @return the total stack memory size in bytes
DieterGraef 0:f9b6112278fe 94 */
DieterGraef 0:f9b6112278fe 95 uint32_t stack_size();
DieterGraef 0:f9b6112278fe 96
DieterGraef 0:f9b6112278fe 97 /** Get the currently unused stack memory for this Thread
DieterGraef 0:f9b6112278fe 98 @return the currently unused stack memory in bytes
DieterGraef 0:f9b6112278fe 99 */
DieterGraef 0:f9b6112278fe 100 uint32_t free_stack();
DieterGraef 0:f9b6112278fe 101
DieterGraef 0:f9b6112278fe 102 /** Get the currently used stack memory for this Thread
DieterGraef 0:f9b6112278fe 103 @return the currently used stack memory in bytes
DieterGraef 0:f9b6112278fe 104 */
DieterGraef 0:f9b6112278fe 105 uint32_t used_stack();
DieterGraef 0:f9b6112278fe 106
DieterGraef 0:f9b6112278fe 107 /** Get the maximum stack memory usage to date for this Thread
DieterGraef 0:f9b6112278fe 108 @return the maximum stack memory usage to date in bytes
DieterGraef 0:f9b6112278fe 109 */
DieterGraef 0:f9b6112278fe 110 uint32_t max_stack();
DieterGraef 0:f9b6112278fe 111
DieterGraef 0:f9b6112278fe 112 /** Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
DieterGraef 0:f9b6112278fe 113 @param signals wait until all specified signal flags set or 0 for any single signal flag.
DieterGraef 0:f9b6112278fe 114 @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
DieterGraef 0:f9b6112278fe 115 @return event flag information or error code.
DieterGraef 0:f9b6112278fe 116 */
DieterGraef 0:f9b6112278fe 117 static osEvent signal_wait(int32_t signals, uint32_t millisec=osWaitForever);
DieterGraef 0:f9b6112278fe 118
DieterGraef 0:f9b6112278fe 119 /** Wait for a specified time period in millisec:
DieterGraef 0:f9b6112278fe 120 @param millisec time delay value
DieterGraef 0:f9b6112278fe 121 @return status code that indicates the execution status of the function.
DieterGraef 0:f9b6112278fe 122 */
DieterGraef 0:f9b6112278fe 123 static osStatus wait(uint32_t millisec);
DieterGraef 0:f9b6112278fe 124
DieterGraef 0:f9b6112278fe 125 /** Pass control to next thread that is in state READY.
DieterGraef 0:f9b6112278fe 126 @return status code that indicates the execution status of the function.
DieterGraef 0:f9b6112278fe 127 */
DieterGraef 0:f9b6112278fe 128 static osStatus yield();
DieterGraef 0:f9b6112278fe 129
DieterGraef 0:f9b6112278fe 130 /** Get the thread id of the current running thread.
DieterGraef 0:f9b6112278fe 131 @return thread ID for reference by other functions or NULL in case of error.
DieterGraef 0:f9b6112278fe 132 */
DieterGraef 0:f9b6112278fe 133 static osThreadId gettid();
DieterGraef 0:f9b6112278fe 134
DieterGraef 0:f9b6112278fe 135 /** Attach a function to be called by the RTOS idle task
DieterGraef 0:f9b6112278fe 136 @param fptr pointer to the function to be called
DieterGraef 0:f9b6112278fe 137 */
DieterGraef 0:f9b6112278fe 138 static void attach_idle_hook(void (*fptr)(void));
DieterGraef 0:f9b6112278fe 139
DieterGraef 0:f9b6112278fe 140 virtual ~Thread();
DieterGraef 0:f9b6112278fe 141
DieterGraef 0:f9b6112278fe 142 private:
DieterGraef 0:f9b6112278fe 143 osThreadId _tid;
DieterGraef 0:f9b6112278fe 144 osThreadDef_t _thread_def;
DieterGraef 0:f9b6112278fe 145 bool _dynamic_stack;
DieterGraef 0:f9b6112278fe 146 };
DieterGraef 0:f9b6112278fe 147
DieterGraef 0:f9b6112278fe 148 }
DieterGraef 0:f9b6112278fe 149 #endif