5.2.1 - Updated I2C files

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Committer:
jacobjohnson
Date:
Mon Feb 27 17:45:05 2017 +0000
Revision:
1:f30bdcd2b33b
Parent:
0:098463de4c5d
changed the inputscale from 1 to 7 in analogin_api.c.  This will need to be changed later, and accessed from the main level, but for now this allows the  adc to read a value from 0 to 3.7V, instead of just up to 1V.;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
group-onsemi 0:098463de4c5d 1
group-onsemi 0:098463de4c5d 2 /** \addtogroup events */
group-onsemi 0:098463de4c5d 3 /** @{*/
group-onsemi 0:098463de4c5d 4 /*
group-onsemi 0:098463de4c5d 5 * System specific implementation
group-onsemi 0:098463de4c5d 6 *
group-onsemi 0:098463de4c5d 7 * Copyright (c) 2016 Christopher Haster
group-onsemi 0:098463de4c5d 8 *
group-onsemi 0:098463de4c5d 9 * Licensed under the Apache License, Version 2.0 (the "License");
group-onsemi 0:098463de4c5d 10 * you may not use this file except in compliance with the License.
group-onsemi 0:098463de4c5d 11 * You may obtain a copy of the License at
group-onsemi 0:098463de4c5d 12 *
group-onsemi 0:098463de4c5d 13 * http://www.apache.org/licenses/LICENSE-2.0
group-onsemi 0:098463de4c5d 14 *
group-onsemi 0:098463de4c5d 15 * Unless required by applicable law or agreed to in writing, software
group-onsemi 0:098463de4c5d 16 * distributed under the License is distributed on an "AS IS" BASIS,
group-onsemi 0:098463de4c5d 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
group-onsemi 0:098463de4c5d 18 * See the License for the specific language governing permissions and
group-onsemi 0:098463de4c5d 19 * limitations under the License.
group-onsemi 0:098463de4c5d 20 */
group-onsemi 0:098463de4c5d 21 #ifndef EQUEUE_PLATFORM_H
group-onsemi 0:098463de4c5d 22 #define EQUEUE_PLATFORM_H
group-onsemi 0:098463de4c5d 23
group-onsemi 0:098463de4c5d 24 #ifdef __cplusplus
group-onsemi 0:098463de4c5d 25 extern "C" {
group-onsemi 0:098463de4c5d 26 #endif
group-onsemi 0:098463de4c5d 27
group-onsemi 0:098463de4c5d 28 #include <stdbool.h>
group-onsemi 0:098463de4c5d 29
group-onsemi 0:098463de4c5d 30 // Currently supported platforms
group-onsemi 0:098463de4c5d 31 //
group-onsemi 0:098463de4c5d 32 // Uncomment to select a supported platform or reimplement this file
group-onsemi 0:098463de4c5d 33 // for a specific target.
group-onsemi 0:098463de4c5d 34 //#define EQUEUE_PLATFORM_POSIX
group-onsemi 0:098463de4c5d 35 //#define EQUEUE_PLATFORM_MBED
group-onsemi 0:098463de4c5d 36
group-onsemi 0:098463de4c5d 37 // Try to infer a platform if none was manually selected
group-onsemi 0:098463de4c5d 38 #if !defined(EQUEUE_PLATFORM_POSIX) \
group-onsemi 0:098463de4c5d 39 && !defined(EQUEUE_PLATFORM_MBED)
group-onsemi 0:098463de4c5d 40 #if defined(__unix__)
group-onsemi 0:098463de4c5d 41 #define EQUEUE_PLATFORM_POSIX
group-onsemi 0:098463de4c5d 42 #elif defined(__MBED__)
group-onsemi 0:098463de4c5d 43 #define EQUEUE_PLATFORM_MBED
group-onsemi 0:098463de4c5d 44 #else
group-onsemi 0:098463de4c5d 45 #warning "Unknown platform! Please update equeue_platform.h"
group-onsemi 0:098463de4c5d 46 #endif
group-onsemi 0:098463de4c5d 47 #endif
group-onsemi 0:098463de4c5d 48
group-onsemi 0:098463de4c5d 49 // Platform includes
group-onsemi 0:098463de4c5d 50 #if defined(EQUEUE_PLATFORM_POSIX)
group-onsemi 0:098463de4c5d 51 #include <pthread.h>
group-onsemi 0:098463de4c5d 52 #endif
group-onsemi 0:098463de4c5d 53
group-onsemi 0:098463de4c5d 54
group-onsemi 0:098463de4c5d 55 // Platform millisecond counter
group-onsemi 0:098463de4c5d 56 //
group-onsemi 0:098463de4c5d 57 // Return a tick that represents the number of milliseconds that have passed
group-onsemi 0:098463de4c5d 58 // since an arbitrary point in time. The granularity does not need to be at
group-onsemi 0:098463de4c5d 59 // the millisecond level, however the accuracy of the equeue library is
group-onsemi 0:098463de4c5d 60 // limited by the accuracy of this tick.
group-onsemi 0:098463de4c5d 61 //
group-onsemi 0:098463de4c5d 62 // Must intentionally overflow to 0 after 2^32-1
group-onsemi 0:098463de4c5d 63 unsigned equeue_tick(void);
group-onsemi 0:098463de4c5d 64
group-onsemi 0:098463de4c5d 65
group-onsemi 0:098463de4c5d 66 // Platform mutex type
group-onsemi 0:098463de4c5d 67 //
group-onsemi 0:098463de4c5d 68 // The equeue library requires at minimum a non-recursive mutex that is
group-onsemi 0:098463de4c5d 69 // safe in interrupt contexts. The mutex section is help for a bounded
group-onsemi 0:098463de4c5d 70 // amount of time, so simply disabling interrupts is acceptable
group-onsemi 0:098463de4c5d 71 //
group-onsemi 0:098463de4c5d 72 // If irq safety is not required, a regular blocking mutex can be used.
group-onsemi 0:098463de4c5d 73 #if defined(EQUEUE_PLATFORM_POSIX)
group-onsemi 0:098463de4c5d 74 typedef pthread_mutex_t equeue_mutex_t;
group-onsemi 0:098463de4c5d 75 #elif defined(EQUEUE_PLATFORM_WINDOWS)
group-onsemi 0:098463de4c5d 76 typedef CRITICAL_SECTION equeue_mutex_t;
group-onsemi 0:098463de4c5d 77 #elif defined(EQUEUE_PLATFORM_MBED)
group-onsemi 0:098463de4c5d 78 typedef unsigned equeue_mutex_t;
group-onsemi 0:098463de4c5d 79 #elif defined(EQUEUE_PLATFORM_FREERTOS)
group-onsemi 0:098463de4c5d 80 typedef UBaseType_t equeue_mutex_t;
group-onsemi 0:098463de4c5d 81 #endif
group-onsemi 0:098463de4c5d 82
group-onsemi 0:098463de4c5d 83 // Platform mutex operations
group-onsemi 0:098463de4c5d 84 //
group-onsemi 0:098463de4c5d 85 // The equeue_mutex_create and equeue_mutex_destroy manage the lifetime
group-onsemi 0:098463de4c5d 86 // of the mutex. On error, equeue_mutex_create should return a negative
group-onsemi 0:098463de4c5d 87 // error code.
group-onsemi 0:098463de4c5d 88 //
group-onsemi 0:098463de4c5d 89 // The equeue_mutex_lock and equeue_mutex_unlock lock and unlock the
group-onsemi 0:098463de4c5d 90 // underlying mutex.
group-onsemi 0:098463de4c5d 91 int equeue_mutex_create(equeue_mutex_t *mutex);
group-onsemi 0:098463de4c5d 92 void equeue_mutex_destroy(equeue_mutex_t *mutex);
group-onsemi 0:098463de4c5d 93 void equeue_mutex_lock(equeue_mutex_t *mutex);
group-onsemi 0:098463de4c5d 94 void equeue_mutex_unlock(equeue_mutex_t *mutex);
group-onsemi 0:098463de4c5d 95
group-onsemi 0:098463de4c5d 96
group-onsemi 0:098463de4c5d 97 // Platform semaphore type
group-onsemi 0:098463de4c5d 98 //
group-onsemi 0:098463de4c5d 99 // The equeue library requires a binary semaphore type that can be safely
group-onsemi 0:098463de4c5d 100 // signaled from interrupt contexts and from inside a equeue_mutex section.
group-onsemi 0:098463de4c5d 101 //
group-onsemi 0:098463de4c5d 102 // The equeue_signal_wait is relied upon by the equeue library to sleep the
group-onsemi 0:098463de4c5d 103 // processor between events. Spurious wakeups have no negative-effects.
group-onsemi 0:098463de4c5d 104 //
group-onsemi 0:098463de4c5d 105 // A counting semaphore will also work, however may cause the event queue
group-onsemi 0:098463de4c5d 106 // dispatch loop to run unnecessarily. For that matter, equeue_signal_wait
group-onsemi 0:098463de4c5d 107 // may even be implemented as a single return statement.
group-onsemi 0:098463de4c5d 108 #if defined(EQUEUE_PLATFORM_POSIX)
group-onsemi 0:098463de4c5d 109 typedef struct equeue_sema {
group-onsemi 0:098463de4c5d 110 pthread_mutex_t mutex;
group-onsemi 0:098463de4c5d 111 pthread_cond_t cond;
group-onsemi 0:098463de4c5d 112 bool signal;
group-onsemi 0:098463de4c5d 113 } equeue_sema_t;
group-onsemi 0:098463de4c5d 114 #elif defined(EQUEUE_PLATFORM_MBED) && defined(MBED_CONF_RTOS_PRESENT)
group-onsemi 0:098463de4c5d 115 typedef unsigned equeue_sema_t[8];
group-onsemi 0:098463de4c5d 116 #elif defined(EQUEUE_PLATFORM_MBED)
group-onsemi 0:098463de4c5d 117 typedef volatile int equeue_sema_t;
group-onsemi 0:098463de4c5d 118 #endif
group-onsemi 0:098463de4c5d 119
group-onsemi 0:098463de4c5d 120 // Platform semaphore operations
group-onsemi 0:098463de4c5d 121 //
group-onsemi 0:098463de4c5d 122 // The equeue_sema_create and equeue_sema_destroy manage the lifetime
group-onsemi 0:098463de4c5d 123 // of the semaphore. On error, equeue_sema_create should return a negative
group-onsemi 0:098463de4c5d 124 // error code.
group-onsemi 0:098463de4c5d 125 //
group-onsemi 0:098463de4c5d 126 // The equeue_sema_signal marks a semaphore as signalled such that the next
group-onsemi 0:098463de4c5d 127 // equeue_sema_wait will return true.
group-onsemi 0:098463de4c5d 128 //
group-onsemi 0:098463de4c5d 129 // The equeue_sema_wait waits for a semaphore to be signalled or returns
group-onsemi 0:098463de4c5d 130 // immediately if equeue_sema_signal had been called since the last
group-onsemi 0:098463de4c5d 131 // equeue_sema_wait. The equeue_sema_wait returns true if it detected that
group-onsemi 0:098463de4c5d 132 // equeue_sema_signal had been called.
group-onsemi 0:098463de4c5d 133 int equeue_sema_create(equeue_sema_t *sema);
group-onsemi 0:098463de4c5d 134 void equeue_sema_destroy(equeue_sema_t *sema);
group-onsemi 0:098463de4c5d 135 void equeue_sema_signal(equeue_sema_t *sema);
group-onsemi 0:098463de4c5d 136 bool equeue_sema_wait(equeue_sema_t *sema, int ms);
group-onsemi 0:098463de4c5d 137
group-onsemi 0:098463de4c5d 138
group-onsemi 0:098463de4c5d 139 #ifdef __cplusplus
group-onsemi 0:098463de4c5d 140 }
group-onsemi 0:098463de4c5d 141 #endif
group-onsemi 0:098463de4c5d 142
group-onsemi 0:098463de4c5d 143 #endif
group-onsemi 0:098463de4c5d 144
group-onsemi 0:098463de4c5d 145 /** @}*/