diff options
author | Anton Staaf <robotboy@chromium.org> | 2014-07-23 14:25:35 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-23 00:04:56 +0000 |
commit | 0a147973bb6a16714925cc7d701b9b6cffc73cb2 (patch) | |
tree | 94e385317bdff8ccc5d06082429b50d62ae7a2d5 /include/util.h | |
parent | ccb45ff8a2285fbee6d87c02789dc7b00250dc82 (diff) | |
download | chrome-ec-0a147973bb6a16714925cc7d701b9b6cffc73cb2.tar.gz |
stm32-USART: Add generic stream based usart driver
This driver can be used to access multiple usarts using an abstract
stream interface. The stream interface can also be used in drivers
for the host interface and USB console interface, providing a
consistent API across all character stream style IO.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
TEST=make buildall -j
Change-Id: Icf567f0b0fa4eb0e9ad4cdb0be8edc31c937a7de
Reviewed-on: https://chromium-review.googlesource.com/209671
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'include/util.h')
-rw-r--r-- | include/util.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/util.h b/include/util.h index c012470a47..8b1e51e2c5 100644 --- a/include/util.h +++ b/include/util.h @@ -56,6 +56,14 @@ #define NULL ((void *)0) #endif +/* + * Convert a pointer to a base struct into a pointer to the struct that + * contains the base struct. This requires knowing where in the contained + * struct the base struct resides, this is the member parameter to downcast. + */ +#define DOWNCAST(pointer, type, member) \ + ((type *)(((uint8_t *) pointer) - offsetof(type, member))) + /* True of x is a power of two */ #define POWER_OF_TWO(x) (x && !(x & (x - 1))) |