Commit Graph

47 Commits (0712b8adf6bbc7eb796d5dac26f95d79d40745ef)

Author SHA1 Message Date
Christopher Haster 75a57ad797 Exposed the network-socket API through mbed.h
Currently this uses the same mechanism used by the rtos to conditionally
include the network-socket API. Perhaps this should be builtin to the
config system?

Note: this does require that the bug-compatible inclusion of mbed.h
be removed to avoid include-order issues.

per @sg-
2016-08-04 11:07:33 -05:00
Martin Kojtal ac34f29f66 Merge pull request #2297 from neilt6/spi-mutex-fix
[HAL] Modified SPI to use shared mutex
2016-07-29 17:30:38 +02:00
Russ Butler 4047ff9576 Create dedicated file for PlatformMutex
Move the PlatformMutex class into a dedicated file to reduce the
number of unnecessary includes.
2016-07-28 14:21:04 -05:00
neilt6 e80b16628d [HAL] Modified SPI to use shared mutex
Modified the SPI class to use a shared mutex for all instances. This is
consistent with I2C and others.
2016-07-28 08:57:59 -06:00
Sam Grove 542fcca670 Merge pull request #2137 from sg-/operators
Remove macro for operators. Enable these as default behavior
2016-07-22 19:01:24 -05:00
Bogdan Marinescu b8ab75db03 Includre rtos.h in mbed.h if present
So that apps don't need to include "rtos.h" explicitly anymore.
2016-07-22 18:08:32 +03:00
Martin Kojtal 51cd3cb972 Merge pull request #2191 from geky/callback-fp-deprecate
[api] Mark FunctionPointer and friends as deprecated
2016-07-22 10:25:07 +01:00
Christopher Haster e806b89df6 Fixed handling of const objects in Callback class
Before, the following results in a compilation error:

    const struct Object *obj;
    void obj_doit(const Object *obj);

    Callback<void()> cb(obj, obj_doit);

This is especially noticable when migrating from the old Thread
constructor, which previously _required_ const.

Short term fix for all cv qualifiers through a C cast:
void *_obj = (void*)obj;
2016-07-20 19:20:32 -05:00
Sam Grove d89c3c18f9 Merge pull request #2158 from c1728p9/singleton_support
Singleton support
2016-07-19 16:34:20 -05:00
0xc0170 edf015ad92 Merge branch 'master' into release
Conflicts:
	tools/export/uvision4.py
	tools/export/uvision5.py
2016-07-19 08:44:34 +01:00
Christopher Haster ad07ab8174 Marked FunctionPointer and friends as deprecated
FunctionPointer/FunctionPointerArg0/FunctionPointerArg1 has been
replaced by the more flexible Callback template class.

For the motivation behind adopting the Callback class:
https://github.com/mbedmicro/mbed/pull/1783
2016-07-18 16:22:21 -05:00
Russ Butler 348b32c3c6 Create singleton class and update code to use it
Create the wrapper class SingletonPtr.  This provides a safe way to
declare and use singletons.  This class allows both the lazy
initialization of a singleton, and allows the singleton to be
garbage collected by the linker if it is never referenced.

This patch also updates the HAL to use SingletonPtr when declaring
singleton mutexes.
2016-07-15 14:37:43 -05:00
Sam Grove 254ae0e109 Remove macro for operators. Enable these as default behavior 2016-07-10 13:47:13 -05:00
0xc0170 24916505e1 mbed lib revision - 122 2016-07-07 12:04:54 +01:00
Christopher Haster 946199183c Minor documentation updates for critical
- extra dereference in cas example
- clarification of incr/decr
2016-07-06 13:06:37 -05:00
Christopher Haster 9067148618 Standardized style of critical.h
per @0xc0170
2016-07-06 13:06:37 -05:00
Christopher Haster 26726cc170 Added proper usage of standard types for critical pointer functions 2016-07-06 13:06:34 -05:00
Christopher Haster cf6f8e33fb Added cas instrinsics for pointer values
- core_util_atomic_cas
- core_util_atomic_incr
- core_util_atomic_decr
2016-07-06 13:04:36 -05:00
Anna Bridge 329f8a10dc Add core_util_ prefix to are_interrupts_enabled() function.
For consistency with other exposed functions from this file, core_util_
prefix should be added.
2016-07-01 15:08:31 +01:00
Anna Bridge 2292794385 Reverse the logic to get_interrupts_disabled() to are_interrupts_enabled()
and update the using functions accordingly.

Usage:
bool interrupts_enabled = are_interrupts_enabled()

Remove superfluos shift in are_interrupts_enabled().
2016-07-01 14:55:53 +01:00
Anna Bridge 9f052bc500 Update function get_interrupts_disabled() to return a bool value rather
than an integer. This removes the need for all users to mask the returned
value with 0x1 to determine interrupt status.
Expose this function externally to allow other users to check interrupt
status in a manner which will work for both cortex-A and cortex-M .
Usage:
bool disabled = get_interrupts_disabled();
2016-07-01 14:53:53 +01:00
Russ Butler 58d15f3007 Add virtual destructor to classes
Add a virtual destructor to classes which have a virtual lock and
unlock.  Remove the virtual qualifier from functions in
InterruptManager since this class cannot be extended.
2016-06-12 21:33:31 +01:00
Sam Grove 4dba251c33 Merge pull request #1896 from geky/align-stack-iar
Added warning about stack alignment limitations on IAR
2016-06-12 17:45:34 +01:00
Russ Butler b174d6a314 Add virtual lock for thread safe classes
Add a virtual lock for the classes which are thread safe.  This
allows the use of a mutex to be overridden.
2016-06-11 17:33:12 +01:00
Russ Butler e4f6e1b327 Update assert and error to be interrupt safe
Add printf functions intended for errors which are safe to call from
interrupts.  Update assert and error to use this function.
2016-06-11 17:33:10 +01:00
Russ Butler a6f611b706 Add sync level documentation to classes
Document public classes to indicate level of protection provided.
2016-06-11 17:33:09 +01:00
Russ Butler feb60784e9 Make core mbed API thread safe
Make the mbed C++ API thread safe by adding a combination of
mutexes and critical sections.  Stub out all mutexes when the
RTOS is not present.
2016-06-11 17:33:02 +01:00
Christopher Haster 0defc77fb7 Added warning about stack alignment limitations on IAR 2016-06-09 22:03:25 -05:00
Russ Butler f3b1d45963 Add functions for atomic access
Add core util functions for atomic increment, atomic decrement and
compare and set.
2016-06-06 10:55:55 +01:00
Christopher Haster 5cdb151193 Changed MBED_PACKED to a macro
Supports both __packed and __attribute__((packed)) styles of attriubtes

MBED_PACKED(struct) foo {
    blablabla
};
2016-06-01 16:10:19 -05:00
geky a08d04c751 Fixed typo in FORCEINLINE definition on IAR
per @c1728p9
2016-06-01 15:27:26 -05:00
geky b7bcb931a8 Fix backwards compatibility for WEAK/PACKED attributes 2016-06-01 15:27:26 -05:00
Christopher Haster 4c7a4de673 Added MBED prefix to attributes 2016-06-01 15:27:26 -05:00
Christopher Haster 3f7fbe696d Added useful attributes supported by supported compilers
Merges compiler-polyfill into hal/api/toolchain.h following the existing
mbed conventions.

tested on:
- GCC
- Clang
- ARMCC (online compiler)
- IAR

attributes:
- PACK
- ALIGN
- UNUSED
- WEAK
- PURE
- FORCEINLINE
- NORETURN
- UNREACHABLE
- DEPRECATED
2016-06-01 15:27:26 -05:00
Anna Bridge 462c917ad0 Add a c based re-entrant critical section API
This includes a generic critical section implementation.  This
implementation also allow a user to start a critical section while
interrupts are already disabled.
2016-05-27 23:27:52 -05:00
Sam Grove 60c862c206 Merge pull request #1795 from 0xc0170/dev_mbedos_additions
Small changes (docs plus assert)
2016-05-28 09:02:04 +08:00
Russ Butler 48fd7d7480 Compatibility changes
Make changes to improve compatibility:
-Include toolchain.h inside mbed.h
-define EXTERN
2016-05-27 10:34:19 -05:00
Jimmy Brisson e690ec0fc5 moved event_callback_t for compatibility with many drivers 2016-05-27 10:28:46 -05:00
Christopher Haster fbbda73faa Update Callback to fix fault in serial interrupts
per @c1728p9

Update the Callback class to handle a NULL thunk by returning 0
rather than trying to call the thunk.  This fixes a crash that occurs
on some targets when the TX uart handler is not attached.

Background:
The K64F HAL uart implementation calls the TX interrupt handler
every time a uart interrupt occurs while the TX register is empty.
It does not check to see if the TX interrupt has been enabled.
This means that the TX interrupt can and typically does get
run on RX events.  This causes a crash with the newer callback
code which did not (prior to this patch) support a NULL thunk.
2016-05-27 10:28:46 -05:00
Christopher Haster a7f4262858 Adopt Callback class in hal 2016-05-27 10:28:46 -05:00
Christopher Haster 2e112f535a Add backward compatiblity for FunctionPointer class using Callback
effectively:
typedef Callback<R(A)> FunctionPointerArg1<R,A>
typedef Callback<R()> FunctionPointerArg1<R,void>
typedef Callback<R()> FunctionPointer
typedef Callback<R()> event_callback_t
2016-05-27 10:28:45 -05:00
Christopher Haster 15db3951df Add Callback, an improved FunctionPointer class
- Adopt C++11 style template arguments, requires rename to Callback
- Add constructor for C style callback functions
- Add constructor for Callbacks
- Add static function for passing to C style callbacks
2016-05-27 10:28:45 -05:00
0xc0170 d898c11e42 api - doxygen improvements, unused parameters fixes
This patch is taken from mbed-drivers master.
2016-05-26 15:07:57 +01:00
0xc0170 ea72444c96 mbed lib revision - 121 2016-05-25 09:57:29 +01:00
0xc0170 f3e11eb36e semihost - fix inline __semihost for IAR (add static)
This was causing errors at my machine (for programs like MBED_10, RTOS_1):

Error[Li005]: no definition for "__semihost" [referenced from
          semihost_api.o(mbed.a)]
[ERROR] Error[Li005]: no definition for "__semihost" [referenced from
          semihost_api.o(mbed.a)]
2016-05-23 09:50:20 +01:00
Mihail Stoyanov ec8512aaab Removed mbed-drivers/mbed.h which breaks compatibility with binary releases due to difference in the inclusion path 2016-05-23 09:14:06 +01:00
Mihail Stoyanov d9734e5a32 Simplify layout:
* /libraries/mbed -> /hal
* /libraries/rtos -> /rtos
2016-05-23 09:13:59 +01:00