Library for MAX31850 thermocouple temperature sensor

Committer:
croberts21
Date:
Wed Jan 23 23:44:57 2019 +0000
Revision:
0:5530bf2d0e94
All files added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
croberts21 0:5530bf2d0e94 1 /**
croberts21 0:5530bf2d0e94 2 * @file LinkedList.h
croberts21 0:5530bf2d0e94 3 * @brief Core Utility - Templated Linked List class
croberts21 0:5530bf2d0e94 4 * @author sam grove
croberts21 0:5530bf2d0e94 5 * @version 1.0
croberts21 0:5530bf2d0e94 6 * @see
croberts21 0:5530bf2d0e94 7 *
croberts21 0:5530bf2d0e94 8 * Copyright (c) 2013
croberts21 0:5530bf2d0e94 9 *
croberts21 0:5530bf2d0e94 10 * Licensed under the Apache License, Version 2.0 (the "License");
croberts21 0:5530bf2d0e94 11 * you may not use this file except in compliance with the License.
croberts21 0:5530bf2d0e94 12 * You may obtain a copy of the License at
croberts21 0:5530bf2d0e94 13 *
croberts21 0:5530bf2d0e94 14 * http://www.apache.org/licenses/LICENSE-2.0
croberts21 0:5530bf2d0e94 15 *
croberts21 0:5530bf2d0e94 16 * Unless required by applicable law or agreed to in writing, software
croberts21 0:5530bf2d0e94 17 * distributed under the License is distributed on an "AS IS" BASIS,
croberts21 0:5530bf2d0e94 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
croberts21 0:5530bf2d0e94 19 * See the License for the specific language governing permissions and
croberts21 0:5530bf2d0e94 20 * limitations under the License.
croberts21 0:5530bf2d0e94 21 */
croberts21 0:5530bf2d0e94 22
croberts21 0:5530bf2d0e94 23 #ifndef LINKEDLIST_H_
croberts21 0:5530bf2d0e94 24 #define LINKEDLIST_H_
croberts21 0:5530bf2d0e94 25
croberts21 0:5530bf2d0e94 26 #include <stdint.h>
croberts21 0:5530bf2d0e94 27 #include "mbed.h"
croberts21 0:5530bf2d0e94 28
croberts21 0:5530bf2d0e94 29 /**
croberts21 0:5530bf2d0e94 30 * @struct node
croberts21 0:5530bf2d0e94 31 * @brief The Linked List structure
croberts21 0:5530bf2d0e94 32 */
croberts21 0:5530bf2d0e94 33 struct node
croberts21 0:5530bf2d0e94 34 {
croberts21 0:5530bf2d0e94 35 void *data; /*!< pointer to list member data */
croberts21 0:5530bf2d0e94 36 struct node *next; /*!< pointer to the next list member */
croberts21 0:5530bf2d0e94 37 };
croberts21 0:5530bf2d0e94 38
croberts21 0:5530bf2d0e94 39 /** Example using the LinkedList Class
croberts21 0:5530bf2d0e94 40 * @code
croberts21 0:5530bf2d0e94 41 * #include "mbed.h"
croberts21 0:5530bf2d0e94 42 * #include "LinkedList.h"
croberts21 0:5530bf2d0e94 43 *
croberts21 0:5530bf2d0e94 44 * LinkedList<node>list;
croberts21 0:5530bf2d0e94 45 *
croberts21 0:5530bf2d0e94 46 * int main()
croberts21 0:5530bf2d0e94 47 * {
croberts21 0:5530bf2d0e94 48 * node *tmp;
croberts21 0:5530bf2d0e94 49 *
croberts21 0:5530bf2d0e94 50 * list.push((char *)"Two\n");
croberts21 0:5530bf2d0e94 51 * list.append((char *)"Three\n");
croberts21 0:5530bf2d0e94 52 * list.append((char *)"Four\n");
croberts21 0:5530bf2d0e94 53 * list.push((char*)"One\n");
croberts21 0:5530bf2d0e94 54 * list.append((char*)"Five\n");
croberts21 0:5530bf2d0e94 55 *
croberts21 0:5530bf2d0e94 56 * for(int i=1; i<=list.length(); i++)
croberts21 0:5530bf2d0e94 57 * {
croberts21 0:5530bf2d0e94 58 * tmp = list.pop(i);
croberts21 0:5530bf2d0e94 59 * printf("%s", (char *)tmp->data);
croberts21 0:5530bf2d0e94 60 * }
croberts21 0:5530bf2d0e94 61 *
croberts21 0:5530bf2d0e94 62 * error("done\n");
croberts21 0:5530bf2d0e94 63 * }
croberts21 0:5530bf2d0e94 64 * @endcode
croberts21 0:5530bf2d0e94 65 */
croberts21 0:5530bf2d0e94 66
croberts21 0:5530bf2d0e94 67 /**
croberts21 0:5530bf2d0e94 68 * @class LinkedList
croberts21 0:5530bf2d0e94 69 * @brief API abstraction for a Linked List
croberts21 0:5530bf2d0e94 70 */
croberts21 0:5530bf2d0e94 71 template<class retT>
croberts21 0:5530bf2d0e94 72 class LinkedList
croberts21 0:5530bf2d0e94 73 {
croberts21 0:5530bf2d0e94 74 protected:
croberts21 0:5530bf2d0e94 75 retT *_head;
croberts21 0:5530bf2d0e94 76
croberts21 0:5530bf2d0e94 77 public:
croberts21 0:5530bf2d0e94 78 /** Create the LinkedList object
croberts21 0:5530bf2d0e94 79 */
croberts21 0:5530bf2d0e94 80 LinkedList();
croberts21 0:5530bf2d0e94 81
croberts21 0:5530bf2d0e94 82 /** Deconstructor for the LinkedList object
croberts21 0:5530bf2d0e94 83 * Removes any members
croberts21 0:5530bf2d0e94 84 */
croberts21 0:5530bf2d0e94 85 ~LinkedList();
croberts21 0:5530bf2d0e94 86
croberts21 0:5530bf2d0e94 87 /** Add a member to the begining of the list
croberts21 0:5530bf2d0e94 88 * @param data - Some data type that is added to the list
croberts21 0:5530bf2d0e94 89 * @return The member that was just inserted (NULL if empty)
croberts21 0:5530bf2d0e94 90 */
croberts21 0:5530bf2d0e94 91 retT *push(void *data);
croberts21 0:5530bf2d0e94 92
croberts21 0:5530bf2d0e94 93 // /** Add a member to some position in the list
croberts21 0:5530bf2d0e94 94 // * @param data - Some data type that is added to the list
croberts21 0:5530bf2d0e94 95 // * @param loc - Place in the list to put the data
croberts21 0:5530bf2d0e94 96 // * @return The member that was just inserted (NULL if empty)
croberts21 0:5530bf2d0e94 97 // */
croberts21 0:5530bf2d0e94 98 // retT *insert(void *data, uint32_t loc);
croberts21 0:5530bf2d0e94 99
croberts21 0:5530bf2d0e94 100 /** Add a member to the end of the list
croberts21 0:5530bf2d0e94 101 * @param data - Some data type that is added to the list
croberts21 0:5530bf2d0e94 102 * @return The member that was just inserted (NULL if empty)
croberts21 0:5530bf2d0e94 103 */
croberts21 0:5530bf2d0e94 104 retT *append(void *data);
croberts21 0:5530bf2d0e94 105
croberts21 0:5530bf2d0e94 106 /** Remove a member from the list
croberts21 0:5530bf2d0e94 107 * @param loc - The location of the member to remove
croberts21 0:5530bf2d0e94 108 * @return The head of the list
croberts21 0:5530bf2d0e94 109 */
croberts21 0:5530bf2d0e94 110 retT *remove(uint32_t loc);
croberts21 0:5530bf2d0e94 111
croberts21 0:5530bf2d0e94 112 /** Get access to a member from the list
croberts21 0:5530bf2d0e94 113 * @param loc - The location of the member to access
croberts21 0:5530bf2d0e94 114 * @return The member that was just requested (NULL if empty or out of bounds)
croberts21 0:5530bf2d0e94 115 */
croberts21 0:5530bf2d0e94 116 retT *pop(uint32_t loc);
croberts21 0:5530bf2d0e94 117
croberts21 0:5530bf2d0e94 118 /** Get the length of the list
croberts21 0:5530bf2d0e94 119 * @return The number of members in the list
croberts21 0:5530bf2d0e94 120 */
croberts21 0:5530bf2d0e94 121 uint32_t length(void);
croberts21 0:5530bf2d0e94 122 };
croberts21 0:5530bf2d0e94 123
croberts21 0:5530bf2d0e94 124 #endif /* LINKEDLIST_H_ */