Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 2:26a5e9b178b7, committed 2014-12-28
- Comitter:
- johnsonzzd
- Date:
- Sun Dec 28 10:03:26 2014 +0000
- Parent:
- 1:a15c639615a9
- Commit message:
- v1.0
Changed in this revision
--- a/basic_types.h Sun Dec 28 09:59:17 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* - * basic_types.h - * - * Created on: 2014年3月5日 - * Author: johnson - */ - - -#ifndef BASIC_TYPES_H_ -#define BASIC_TYPES_H_ - -#include <stdint.h> - -#ifndef u8 -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; -typedef volatile u8 vu8; -typedef volatile u32 vu32; -typedef volatile u64 vu64; -#endif - -#ifndef FALSE -#define FALSE 0 -#define TRUE !FALSE -#endif - -union CONV_INT_F{ - float f; - u32 t; -}; - -#ifndef NULL -#define NULL (0) -#endif - - -//物理常数 -#define GRAVITY 9.8 //2g量程,重力加速度常数 -#define PI2 6.28318530717959 //2*pi - -//大小端转换,8字节 -# define T64(from) \ - ( (((from) & ((u64)0xFF << 56)) >> 56) \ - | (((from) & ((u64)0xFF << 48)) >> 40) \ - | (((from) & ((u64)0xFF << 40)) >> 24) \ - | (((from) & ((u64)0xFF << 32)) >> 8) \ - | (((from) & ((u64)0xFF << 24)) << 8) \ - | (((from) & ((u64)0xFF << 16)) << 24) \ - | (((from) & ((u64)0xFF << 8)) << 40) \ - | (((from) & (u64)0xFF) << 56) ) - -//大小端转换,4字节 -# define T32(from) \ - ( (((from) & ((u32)0xFF << 24)) >> 24) \ - | (((from) & ((u32)0xFF << 16)) >> 8) \ - | (((from) & ((u32)0xFF << 8)) << 8) \ - | (((from) & (u32)0xFF) << 24) ) - -//大小端转换,2字节 -# define T16(from) \ - ( (((from) & ((u16)0xFF << 8)) >> 8) \ - | (((from) & (u16)0xFF) << 8) ) - -__inline float T32f(float x) -{ - union conv - { - float f; - unsigned int t; - } c; - - c.f=x; - c.t=T32(c.t); - return c.f; -} - -#define ASSERT(EX) \ -if (!(EX)) \ -{ \ - volatile char dummy = 0; \ - debug_msg("(%s) assert failed at %s:%d \n", #EX, __FUNCTION__, __LINE__);\ - while (dummy == 0); \ -} - -#define ALIGN_SIZE 4 - -/** - * @ingroup BasicDef - * - * @def RT_ALIGN(size, align) - * Return the most contiguous size aligned at specified width. RT_ALIGN(13, 4) - * would return 16. - */ -#define ALIGN(size, align) (((size) + (align) - 1) & ~((align) - 1)) - -/** - * @ingroup BasicDef - * - * @def RT_ALIGN_DOWN(size, align) - * Return the down number of aligned at specified width. RT_ALIGN_DOWN(13, 4) - * would return 12. - */ -#define ALIGN_DOWN(size, align) ((size) & ~((align) - 1)) - -#endif /* BASIC_TYPES_H_ */
--- a/main.cpp Sun Dec 28 09:59:17 2014 +0000 +++ b/main.cpp Sun Dec 28 10:03:26 2014 +0000 @@ -1,4 +1,4 @@ -#include "main.h" +#include "mbed.h" #include "AD7792.h" Serial pc(SERIAL_TX, SERIAL_RX);
--- a/main.h Sun Dec 28 09:59:17 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#ifndef __MAIN_H -#define __MAIN_H - -#include "mbed.h" -#include "basic_types.h" -#include "AD7792.h" - -#endif /* __MAIN_H */ \ No newline at end of file