new file: include/_hal_uart_dma.c
new file: include/_hal_uart_isr.c new file: include/hal_adc.c new file: include/hal_adc.h new file: include/hal_aes.h new file: include/hal_assert.c new file: include/hal_assert.h new file: include/hal_board.h new file: include/hal_board_cfg.h new file: include/hal_ccm.h new file: include/hal_defs.h new file: include/hal_dma.c new file: include/hal_dma.h new file: include/hal_drivers.c new file: include/hal_drivers.h new file: include/hal_flash.c new file: include/hal_flash.h new file: include/hal_key.c new file: include/hal_key.h new file: include/hal_lcd.c new file: include/hal_lcd.h new file: include/hal_led.c new file: include/hal_led.h new file: include/hal_mac_cfg.h new file: include/hal_mcu.h new file: include/hal_oad.c new file: include/hal_oad.h new file: include/hal_ota.c new file: include/hal_ota.h new file: include/hal_rpc.h new file: include/hal_sleep.c new file: include/hal_sleep.h new file: include/hal_startup.c new file: include/hal_timer.c new file: include/hal_timer.h new file: include/hal_types.h new file: include/hal_uart.c new file: include/hal_uart.h
This commit is contained in:
146
include/hal_defs.h
Normal file
146
include/hal_defs.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/**************************************************************************************************
|
||||
Filename: hal_defs.h
|
||||
Revised: $Date: 2014-11-19 13:29:24 -0800 (Wed, 19 Nov 2014) $
|
||||
Revision: $Revision: 41175 $
|
||||
|
||||
Description: This file contains useful macros and data types
|
||||
|
||||
|
||||
Copyright 2005-2014 Texas Instruments Incorporated. All rights reserved.
|
||||
|
||||
IMPORTANT: Your use of this Software is limited to those specific rights
|
||||
granted under the terms of a software license agreement between the user
|
||||
who downloaded the software, his/her employer (which must be your employer)
|
||||
and Texas Instruments Incorporated (the "License"). You may not use this
|
||||
Software unless you agree to abide by the terms of the License. The License
|
||||
limits your use, and you acknowledge, that the Software may not be modified,
|
||||
copied or distributed unless embedded on a Texas Instruments microcontroller
|
||||
or used solely and exclusively in conjunction with a Texas Instruments radio
|
||||
frequency transceiver, which is integrated into your product. Other than for
|
||||
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
|
||||
works of, modify, distribute, perform, display or sell this Software and/or
|
||||
its documentation for any purpose.
|
||||
|
||||
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
|
||||
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
||||
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
|
||||
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
|
||||
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
|
||||
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
|
||||
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
|
||||
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
|
||||
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
|
||||
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
|
||||
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
|
||||
|
||||
Should you have any questions regarding your right to use this Software,
|
||||
contact Texas Instruments Incorporated at www.TI.com.
|
||||
**************************************************************************************************/
|
||||
|
||||
#ifndef HAL_DEFS_H
|
||||
#define HAL_DEFS_H
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Macros
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef BV
|
||||
#define BV(n) (1 << (n))
|
||||
#endif
|
||||
|
||||
#ifndef BF
|
||||
#define BF(x,b,s) (((x) & (b)) >> (s))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(n,m) (((n) < (m)) ? (n) : (m))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(n,m) (((n) < (m)) ? (m) : (n))
|
||||
#endif
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(n) (((n) < 0) ? -(n) : (n))
|
||||
#endif
|
||||
|
||||
|
||||
/* takes a byte out of a uint32 : var - uint32, ByteNum - byte to take out (0 - 3) */
|
||||
#define BREAK_UINT32( var, ByteNum ) \
|
||||
(uint8)((uint32)(((var) >>((ByteNum) * 8)) & 0x00FF))
|
||||
|
||||
#define BUILD_UINT32(Byte0, Byte1, Byte2, Byte3) \
|
||||
((uint32)((uint32)((Byte0) & 0x00FF) \
|
||||
+ ((uint32)((Byte1) & 0x00FF) << 8) \
|
||||
+ ((uint32)((Byte2) & 0x00FF) << 16) \
|
||||
+ ((uint32)((Byte3) & 0x00FF) << 24)))
|
||||
|
||||
#define BUILD_UINT16(loByte, hiByte) \
|
||||
((uint16)(((loByte) & 0x00FF) + (((hiByte) & 0x00FF) << 8)))
|
||||
|
||||
#define HI_UINT16(a) (((a) >> 8) & 0xFF)
|
||||
#define LO_UINT16(a) ((a) & 0xFF)
|
||||
|
||||
#define BUILD_UINT8(hiByte, loByte) \
|
||||
((uint8)(((loByte) & 0x0F) + (((hiByte) & 0x0F) << 4)))
|
||||
|
||||
#define HI_UINT8(a) (((a) >> 4) & 0x0F)
|
||||
#define LO_UINT8(a) ((a) & 0x0F)
|
||||
|
||||
// Write the 32bit value of 'val' in little endian format to the buffer pointed
|
||||
// to by pBuf, and increment pBuf by 4
|
||||
#define UINT32_TO_BUF_LITTLE_ENDIAN(pBuf,val) \
|
||||
do { \
|
||||
*(pBuf)++ = ((((uint32)(val)) >> 0) & 0xFF); \
|
||||
*(pBuf)++ = ((((uint32)(val)) >> 8) & 0xFF); \
|
||||
*(pBuf)++ = ((((uint32)(val)) >> 16) & 0xFF); \
|
||||
*(pBuf)++ = ((((uint32)(val)) >> 24) & 0xFF); \
|
||||
} while (0)
|
||||
|
||||
// Return the 32bit little-endian formatted value pointed to by pBuf, and increment pBuf by 4
|
||||
#define BUF_TO_UINT32_LITTLE_ENDIAN(pBuf) (((pBuf) += 4), BUILD_UINT32((pBuf)[-4], (pBuf)[-3], (pBuf)[-2], (pBuf)[-1]))
|
||||
|
||||
#ifndef CHECK_BIT
|
||||
#define CHECK_BIT(DISCS, IDX) ((DISCS) & (1<<(IDX)))
|
||||
#endif
|
||||
#ifndef GET_BIT
|
||||
#define GET_BIT(DISCS, IDX) (((DISCS)[((IDX) / 8)] & BV((IDX) % 8)) ? TRUE : FALSE)
|
||||
#endif
|
||||
#ifndef SET_BIT
|
||||
#define SET_BIT(DISCS, IDX) (((DISCS)[((IDX) / 8)] |= BV((IDX) % 8)))
|
||||
#endif
|
||||
#ifndef CLR_BIT
|
||||
#define CLR_BIT(DISCS, IDX) (((DISCS)[((IDX) / 8)] &= (BV((IDX) % 8) ^ 0xFF)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This macro is for use by other macros to form a fully valid C statement.
|
||||
* Without this, the if/else conditionals could show unexpected behavior.
|
||||
*
|
||||
* For example, use...
|
||||
* #define SET_REGS() st( ioreg1 = 0; ioreg2 = 0; )
|
||||
* instead of ...
|
||||
* #define SET_REGS() { ioreg1 = 0; ioreg2 = 0; }
|
||||
* or
|
||||
* #define SET_REGS() ioreg1 = 0; ioreg2 = 0;
|
||||
* The last macro would not behave as expected in the if/else construct.
|
||||
* The second to last macro will cause a compiler error in certain uses
|
||||
* of if/else construct
|
||||
*
|
||||
* It is not necessary, or recommended, to use this macro where there is
|
||||
* already a valid C statement. For example, the following is redundant...
|
||||
* #define CALL_FUNC() st( func(); )
|
||||
* This should simply be...
|
||||
* #define CALL_FUNC() func()
|
||||
*
|
||||
* (The while condition below evaluates false without generating a
|
||||
* constant-controlling-loop type of warning on most compilers.)
|
||||
*/
|
||||
#define st(x) do { x } while (__LINE__ == -1)
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
*/
|
||||
#endif
|
||||
Reference in New Issue
Block a user